QObject
Z DooBLER wiki
Spis treści |
Wstęp
QObject jest klasą bazową dla wszystkich objektów QT Więcej...
| Tekst oryginalny |
|---|
| The QObject class is the base class of all Qt objects. |
#include <QObject>
Inherited by Phonon::AudioOutput, Phonon::BackendCapabilities::Notifier, Phonon::Effect, Phonon::GlobalConfig, Phonon::MediaObject, Q3Accel, Q3Action, Q3Canvas, Q3Dns, Q3DragObject, Q3EditorFactory, Q3FileIconProvider, Q3NetworkOperation, Q3NetworkProtocol, Q3Process, Q3ServerSocket, Q3Signal, Q3SqlForm, Q3StyleSheet, Q3UrlOperator, Q3WhatsThis, QAbstractEventDispatcher, QAbstractFontEngine, QAbstractItemDelegate, QAbstractItemModel, QAbstractMessageHandler, QAbstractTextDocumentLayout, QAbstractUriResolver, QAccessibleBridgePlugin, QAccessiblePlugin, QAction, QActionGroup, QAssistantClient, QAxFactory, QAxObject, QAxScript, QAxScriptManager, QButtonGroup, QClipboard, QCompleter, QCopChannel, QCoreApplication, QDataWidgetMapper, QDBusAbstractAdaptor, QDBusAbstractInterface, QDBusServer, QDecorationPlugin, QDesignerFormEditorInterface, QDesignerFormWindowManagerInterface, QDirectPainter, QDrag, QEventLoop, QExtensionFactory, QExtensionManager, QFileSystemWatcher, QFontEnginePlugin, QFtp, QFutureWatcher, QGraphicsItemAnimation, QGraphicsScene, QGraphicsSvgItem, QGraphicsTextItem, QGraphicsWidget, QHelpEngineCore, QHelpSearchEngine, QHttp, QIconEnginePlugin, QIconEnginePluginV2, QImageIOPlugin, QInputContext, QInputContextPlugin, QIODevice, QItemSelectionModel, QKbdDriverPlugin, QLayout, QLibrary, QLocalServer, QMimeData, QMouseDriverPlugin, QMovie, QNetworkAccessManager, QNetworkCookieJar, QObjectCleanupHandler, QPictureFormatPlugin, QPluginLoader, QScreenDriverPlugin, QScriptEngine, QScriptExtensionPlugin, QSessionManager, QSettings, QSharedMemory, QShortcut, QSignalMapper, QSignalSpy, QSocketNotifier, QSound, QSqlDriver, QSqlDriverPlugin, QStyle, QStylePlugin, QSvgRenderer, QSyntaxHighlighter, QSystemTrayIcon, QTcpServer, QTextCodecPlugin, QTextDocument, QTextObject, QThread, QThreadPool, QTimeLine, QTimer, QTranslator, QUiLoader, QUndoGroup, QUndoStack, QValidator, QWebFrame, QWebHistoryInterface, QWebPage, QWebPluginFactory, QWidget, QWSClient, QWSInputMethod, and QWSServer.
Note: All the functions in this class are reentrant, except connect(), connect(), disconnect(), and disconnect().
Właściwości
- objectName : QString
Publiczne funkcje
- QObject ( QObject * parent = 0 )
- virtual ~QObject ()
- bool blockSignals ( bool block )
- const QObjectList & children () const
- bool connect ( const QObject * sender, const char * signal, const char * method, Qt::ConnectionType type = Qt::AutoCompatConnection ) const
- bool disconnect ( const char * signal = 0, const QObject * receiver = 0, const char * method = 0 )
- bool disconnect ( const QObject * receiver, const char * method = 0 )
- void dumpObjectInfo ()
- void dumpObjectTree ()
- QList<QByteArray> dynamicPropertyNames () const
- virtual bool event ( QEvent * e )
- virtual bool eventFilter ( QObject * watched, QEvent * event )
- T findChild ( const QString & name = QString() ) const
- QList<T> findChildren ( const QString & name = QString() ) const
- QList<T> findChildren ( const QRegExp & regExp ) const
- bool inherits ( const char * className ) const
- void installEventFilter ( QObject * filterObj )
- bool isWidgetType () const
- void killTimer ( int id )
- virtual const QMetaObject * metaObject () const
- void moveToThread ( QThread * targetThread )
- QString objectName () const
- QObject * parent () const
- QVariant property ( const char * name ) const
- void removeEventFilter ( QObject * obj )
- void setObjectName ( const QString & name )
- void setParent ( QObject * parent )
- bool setProperty ( const char * name, const QVariant & value )
- bool signalsBlocked () const
- int startTimer ( int interval )
- QThread * thread () const
Publiczne sloty
- void deleteLater ()
Sygnały
- void destroyed ( QObject * obj = 0 )
Static Public Members
- bool connect ( const QObject * sender, const char * signal, const QObject * receiver, const char * method, Qt::ConnectionType type = Qt::AutoCompatConnection )
- bool disconnect ( const QObject * sender, const char * signal, const QObject * receiver, const * * char * method )
- const QMetaObject staticMetaObject
- QString tr ( const char * sourceText, const char * comment = 0, int n = -1 )
- QString trUtf8 ( const char * sourceText, const char * comment = 0, int n = -1 )
Chronione funkcje
- virtual void childEvent ( QChildEvent * event )
- virtual void connectNotify ( const char * signal )
- virtual void customEvent ( QEvent * event )
- virtual void disconnectNotify ( const char * signal )
- int receivers ( const char * signal ) const
- QObject * sender () const
- virtual void timerEvent ( QTimerEvent * event )
Related Non-Members
- typedef QObjectList
- T qFindChild ( const QObject * obj, const QString & name )
- QList<T> qFindChildren ( const QObject * obj, const QString & name )
- QList<T> qFindChildren ( const QObject * obj, const QRegExp & regExp )
- T qobject_cast ( QObject * object )
Makra
- Q_CLASSINFO ( Name, Value )
- Q_ENUMS ( ... )
- Q_FLAGS ( ... )
- Q_INTERFACES ( ... )
- Q_OBJECT
- Q_PROPERTY ( ... )
Opis szczegółowy
QObject jest klasą bazową dla wszystkich obiektów QT
| Tekst oryginalny |
|---|
| The QObject class is the base class of all Qt objects. |
QObject jest sercem obiektowego modelu QT. Najważniejszą cechą tego modelu jest bardzo wszechstronny mechanizm komunikacji między obiektami korzystający z tzw. sygnałów i slotów. Możliwe jest połączenie sygnału ze slotem dzięki connect() i zniszczenie tego połączenia dzięki disconnect(). Aby zapobiec nigdy nie kończącemu się zapętlonemu połączeniu możliwe jest tymczasowe blokowanie sygnałów przez zastosowanie blockSignals(). Chronione funkcje connectNotify() i disconnectNotify() umożliwiają śledzenie komunikacji.
| Tekst oryginalny |
|---|
| QObject is the heart of the Qt object model. The central feature in this model is a very powerful mechanism for seamless object communication called signals and slots. You can connect a signal to a slot with connect() and destroy the connection with disconnect(). To avoid never ending notification loops you can temporarily block signals with blockSignals(). The protected functions connectNotify() and disconnectNotify() make it possible to track connections. |
Obiekty układają same siebie w drzewo obiektów. Kiedy tworzony jest QObject z innym obiektem jako rodzicemn, tworzony obiekt automatyczie dodaje się do listy children() rodzica. Rodzic przejmuje kontrolę nad swoimi dziećmi np. dzieci są automatycznie usuwane w destruktorze rodzica. Możliwe jest poszukiwanie obiektu po nazwie i opcjonalnie po typie przy użyciu findChild() lub findChildren().
| Tekst oryginalny |
|---|
| QObjects organize themselves in object trees. When you create a QObject with another object as parent, the object will automatically add itself to the parent's children() list. The parent takes ownership of the object i.e. it will automatically delete its children in its destructor. You can look for an object by name and optionally type using findChild() or findChildren(). |
| Tekst oryginalny |
|---|
| Every object has an objectName() and its class name can be found via the corresponding metaObject() (see QMetaObject::className()). You can determine whether the object's class inherits another class in the QObject inheritance hierarchy by using the inherits() function. |
Kiedy obiekt jest niszczony, emituje on sygnał destroyed(). Możliew jest przechwycenie tego sygnału aby uniknąć nie połączonych z niczym referencji do QObjects.
| Tekst oryginalny |
|---|
| When an object is deleted, it emits a destroyed() signal. You can catch this signal to avoid dangling references to QObjects. |
| Tekst oryginalny |
|---|
| QObjects can receive events through event() and filter the events of other objects. See installEventFilter() and eventFilter() for details. A convenience handler, childEvent(), can be reimplemented to catch child events. |
| Tekst oryginalny |
|---|
| Events are delivered in the thread in which the object was created; see Thread Support in Qt and thread() for details. Note that event processing is not done at all for QObjects with no thread affinity (thread() returns zero). Use the moveToThread() function to change the thread affinity for an object and its children (the object cannot be moved if it has a parent). |
Ostatnie lecz równie ważne, QObject zapewnia podstawową obsługę timerów w QT; zobacz QTimer aby dowiedzieć się wiecej o timerach.
| Tekst oryginalny |
|---|
| Last but not least, QObject provides the basic timer support in Qt; see QTimer for high-level support for timers. |
| Tekst oryginalny |
|---|
| Notice that the Q_OBJECT macro is mandatory for any object that implements signals, slots or properties. You also need to run the Meta Object Compiler on the source file. We strongly recommend the use of this macro in all subclasses of QObject regardless of whether or not they actually use signals, slots and properties, since failure to do so may lead certain functions to exhibit strange behavior. |
Wszystkie widżety QT dziedziczą z QObject. Pomocną funkcją jest isWidgetType(), która zwraca czy obiekt jest widżetem. Jest to o wiele szybsze od qobject_cast<QWidget *>(obj) lub obj->inherits("QWidget").
| Tekst oryginalny |
|---|
| All Qt widgets inherit QObject. The convenience function isWidgetType() returns whether an object is actually a widget. It is much faster than qobject_cast<QWidget *>(obj) or obj->inherits("QWidget"). |
| Tekst oryginalny |
|---|
| Some QObject functions, e.g. children(), return a QObjectList. QObjectList is a typedef for QList<QObject *>. |
Opis Właściwości
objectName
objectName : QString
Ta właściwość przechowuje nazwę obiektu.
Możliwe jest wyszukanie obiektu po nazwie (i typie) przy użyciu findChild(). Możliwe jest szukanie grupy obiektów dzięki findChildren().
| Tekst oryginalny |
|---|
| This property holds the name of this object.
You can find an object by name (and type) using findChild(). You can find a set of objects with findChildren(). |
qDebug("MyClass::setPrecision(): (%s) invalid precision %f",
qPrintable(objectName()), newPrecision);
Access functions: QString objectName () const void setObjectName ( const QString & name )
See also metaObject() and QMetaObject::className().
Opis funkcji
QObject::QObject
QObject::QObject ( QObject * parent = 0 )
Constructs an object with parent object parent.
The parent of an object may be viewed as the object's owner. For instance, a dialog box is the parent of the OK and Cancel buttons it contains.
The destructor of a parent object destroys all child objects.
Setting parent to 0 constructs an object with no parent. If the object is a widget, it will become a top-level window.
See also parent(), findChild(), and findChildren().
QObject::~QObject () [virtual]
Destroys the object, deleting all its child objects.
All signals to and from the object are automatically disconnected, and any pending posted events for the object are removed from the event queue. However, it is often safer to use deleteLater() rather than deleting a QObject subclass directly.
Warning: All child objects are deleted. If any of these objects are on the stack or global, sooner or later your program will crash. We do not recommend holding pointers to child objects from outside the parent. If you still do, the destroyed() signal gives you an opportunity to detect when an object is destroyed.
Warning: Deleting a QObject while pending events are waiting to be delivered can cause a crash. You must not delete the QObject directly if it exists in a different thread than the one currently executing. Use deleteLater() instead, which will cause the event loop to delete the object after all pending events have been delivered to it.
See also deleteLater().
inne
Ten artykuł jest tylko zalążkiem.
Możesz pomóc poprzez rozszeszenie tego artykułu.
Tłumaczenie na podstawie oryginalnej dokumentacji ze strony http://doc.trolltech.com
Tekst oryginału http://doc.trolltech.com/4.4/qobject.html
