QObject

Z DooBLER wiki

Spis treści


Wstęp

QObject jest klasą bazową dla wszystkich objektów QT Więcej...


#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

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


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.


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().




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.






Ostatnie lecz równie ważne, QObject zapewnia podstawową obsługę timerów w QT; zobacz QTimer aby dowiedzieć się wiecej o timerach.




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").




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().


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

Osobiste
Kategorie główne
Reklamy
Zaprzyjaźnione strony