QtBase  v6.3.1
Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Friends | Related Functions | List of all members
QObject Class Reference

The QObject class is the base class of all Qt objects. More...

#include <qobject.h>

Inherited by $NS::$CLS, Abstract_DBus_Interface, AccessibilityInspector, AccessibilitySceneManager, AlmostPlugin, AndroidConnectivityManager, AnimatedLayout, AnimationObject, AnimationObject, AnimationObject, AnimationObject, AutoConnectReceiver, AutoConnectSender, AutoMetaTypeObject, BBB::Foo, BackslashNewlines, Base, BaseDestroyed, BaseObject, BasicToolsPlugin, BenchQHeaderView, BenchmarkQtJson, BlehObject, BlendBench, BlockOnReadStdOut, BlockingQueuedDestroyRaceObject, CMainWindowTimer, CTestObject, CTestObjectOverloads, CToolBarTimer, CXX11TrailingReturn, ChildObject, ClassInfoTestObjectA, ClassWithPropertyWithoutREAD, ClassWithWrongNOTIFY, Client, ConnectByNameNotifyReceiverObject, ConnectByNameNotifySenderObject, ConnectToSender, ConnectWithReferenceObject, Constructable, ContentsChangeHandler, ContextObject, Controller, Coordinate, CountedExceptionThrower, Counter, CppAttribute, CursorListener, CursorPosSignalSpy, CursorPositionChangedRecorder, CursorPositionChangedRecorder, CustomMultiInheritanceObject, CustomObject, CustomReadObject, CustomWriteObject, DBusConnection, DBus_PendingCall_Interface, DBus_PendingReply_Interface, DBus_Process_String_Interface, DataReader, DataReader, DatabaseThreadObject, DebugPlugin, DefaultArguments, DelayedAction, DeleteReceiverRaceReceiver, DeleteThisReceiver, DeliverInDefinedOrder::Object, Derived, Derived, DerivedChild, DerivedParent, DestroyedListener, DialogRejecter, DirInIncludePath, DisconnectObject, DisconnectRaceSenderObject, Disconnector, DispatcherWatcher, DnsManager, DontBlockEvents, DownloadManager, DownloadManager, DownloadManager, DtlsAssociation, DtlsServer, DtlsServer, Dummy, DummyDataGenerator, DummyObject, DummyObject, EchoPlugin, EmitToDestroyedClass::Base, EnumFlagsTester, EventCounterSpy, EventFilter, EventFilter, EventFilter, EventGenerator, EventLoopExecutor, EventLoopExiter, EventLoopNester, EventSpy< T >, EventSpy< T >, EventSpy< T >, EventSpy< T >, EventSpy< T >, EventSpy< T >, EventSpy< T >, EventSpy< T >, EventSpy< T >, EventTarget, EventTester, EventWithNotifier, EventsBench, EventsFactory, ExceptionThrower, ExecCloseHelper, Exit_Object, ExpectedEventList, ExplicitOverrideControlBase, ExportedFinalTestClassCpp11, ExtraFiltersPlugin, FileSystemWatcherSpy, FilterObject, FinalTestClassCpp11, FindTestData, FinishedTestObject, FlickableTicker [private], Foo, Foo, Foo, Foo, Foo, Foo, Foo::Bar, Foo::Baz, FooObject, ForwardDeclareArguments, ForwardDeclaredParamClass, FragmentToy, FunctionWithAttributes, FunctorArgDifferenceObject, GSuggestCompletion, GetAndEverythingShouldBePipelinedReceiver, GetEmptyWithPipeliningReceiver, GetFromHttpIntoBuffer2Client [private], GetFromHttpIntoBuffer2Server [private], GetMultipleWithPrioritiesReceiver, GetSenderObject, GlobalPostedEventsCountObject, GuiTester, HaikuViewProxy, HaikuWindowProxy, HoverPoints, HttpAbortHelper, HttpDownloadPerformanceClient [private], HttpDownloadPerformanceClientDownloadBuffer [private], HttpDownloadPerformanceServer [private], HttpReUsingConnectionFromFinishedSlot, HttpReceiver, HttpRecursiveCreationHelper, HttpsRequestChainHelper, IfdefedClass, ImageItem, InputItem, Interface, InvokableBeforeInline, InvokableBeforeReturnType, InvokeCounter, Item, ItemMover, Job, JobObject, JobObject, JsonTestPlugin, KDAB, KeyPressEater, LabelSlider, LanguageTestStateMachine, ListenerObject, LiveLockTester, LongLastingSlotClass, LookupAborter, LookupReceiver, LotsOfSignals, LotsOfSignalsAndSlots, ManyArgumentObject, ManySignals, MaxWarnings, MenuCloser, MetaType, MetaType, MetaType, MetaType, MethodTest1, MethodTest2, MethodTest3, MethodTest4, MethodTest5, MethodTest6, MethodTest7, MethodTest8, MethodTest9, MethodTestObject, MiniHttpServerConnection, MiniSocks5ResponseHandler, MixingWithTimersHelper, ModelChangeCommand, ModelObserver, ModelSignalSpy, MoveToThreadObject, MyBooooooostishClass, MyClass, MyClass, MyClass, MyClass, MyClass, MyClass, MyClass, MyDBusObject, MyEditor, MyErrorObject, MyFirstBenchmark, MyFirstTest, MyInstance, MyNamespace::ClassWithChangedSignal, MyNamespace::ClassWithSetterGetterSignals, MyNamespace::MyClass, MyNamespace::MyClass2, MyObject, MyObject, MyObject, MyObject, MyObject, MyObject, MyObject, MyObject, MyObject, MyObject, MyObject, MyObject, MyObject, MyObject, MyObject, MyObject, MyObjectUnknownType, MyObjectWithoutInterface, MyPrivateInitStuff, MyQObjectFromGadget, MyTestClass, MyTestClass, MyUrlHandler, MyWrapObject, NS_A::NS_B::TestObject, NS_A::NS_Main::TestMain, NamespaceWithConstructibleClass::ConstructibleClass, NativeEventList, NoDefaultContructorArguments, NoMetaObject, NormalizeObject, NotificationClient, Object, Object, Object1, Object1, Object2, Object2, Object2, Object3, Object3, Object4, Object5, Object5, Object6, Object6, Object7, Object7, Object8, Object8, Object9, Object9, ObjectA, ObjectDeleter, ObjectF, ObservingObject, OldStyleCast, Operation, OrderHelper, Os9Newlines, OtherObject, OverloadObject, Parser, PeerManager, Ping, PingPong, PixmapItem, PlatformWindowFilter, Plugin1, Plugin2, PluginClass, Pong, Pong, PressDelayHandler, ProcessEventsAlwaysSendsPostedEventsObject, ProcessEventsOnlySendsQueuedEvents, PropertyObject, PropertyTest1, PropertyTest2, PropertyTest3, PropertyTest4, PropertyTest_ag, PropertyTest_ao, PropertyTest_as, PropertyTest_av, PropertyTest_ay, PropertyTest_b, PropertyTest_d, PropertyTest_g, PropertyTest_h, PropertyTest_n, PropertyTest_o, PropertyTest_q, PropertyTest_s, PropertyTest_t, PropertyTest_u, PropertyTest_v, PropertyTest_x, PropertyTest_y, PropertyTester, Provider, ProximityEventFilter, PureVirtualSignalsTest, QAbstractAnimation, QAbstractAnimationTimer, QAbstractEventDispatcher, QAbstractItemDelegate, QAbstractItemModel, QAbstractItemModelTester, QAbstractNetworkCache, QAbstractSocketEngine, QAbstractTextDocumentLayout, QAccessibleBridgePlugin, QAccessibleCache, QAccessiblePlugin, QAction, QActionGroup, QAndroidPlatformScreen, QAndroidPlatformServices, QAndroidServicePrivate, QAnimationDriver, QBasicDrag, QBsdKeyboardHandler, QBsdMouseHandler, QButtonGroup, QCALayerBackingStore, QClipboard, QCocoaClipboard, QCocoaIntegration, QCocoaWindow, QCompleter, QCoreApplication, QCustomTypeChecker, QDBusAbstractAdaptor, QDBusAbstractInterfaceBase, QDBusAdaptorConnector, QDBusConnectionDispatchEnabler, QDBusConnectionPrivate, QDBusMenuConnection, QDBusMessageSpy, QDBusPendingCallWatcher, QDBusPendingCallWatcherHelper, QDBusServer, QDBusServiceWatcher, QDBusSignalSpy, QDBusSpy, QDBusVirtualObject, QDataWidgetMapper, QDeviceClosedNotifier, QDeviceDiscovery, QDnsLookup, QDnsLookupRunnable, QDrag, QDragManager, QDtls, QDtlsClientVerifier, QEglFSCursorDeviceListener, QEglFSDeviceIntegrationPlugin, QEglFSKmsEventHost, QEglFSKmsGbmCursorDeviceListener, QEglFSKmsInterruptHandler, QEvdevKeyboardHandler, QEvdevKeyboardManager, QEvdevMouseHandler, QEvdevMouseManager, QEvdevTabletHandler, QEvdevTabletManager, QEvdevTouchManager, QEvdevTouchScreenHandler, QEventLoop, QFactoryLoader, QFbCursorDeviceListener, QFbScreen, QFbVtHandler, QFileSelector, QFileSystemWatcher, QFileSystemWatcherEngine, QFontCache, QFutureWatcherBase, QGenericPlugin, QGesture, QGestureManager, QGraphicsAnchor, QGraphicsEffect, QGraphicsEffectSource, QGraphicsItemAnimation, QGraphicsObject, QGraphicsScene, QGraphicsSceneIndex, QGraphicsTransform, QHaikuWindow, QHostInfoResult, QHttp2ProtocolHandler, QHttpMultiPart, QHttpNetworkConnection, QHttpNetworkConnectionChannel, QHttpNetworkReply, QHttpThreadDelegate, QIODevice, QIOSApplicationState, QIOSAssetData, QIOSContext, QIOSScreen, QIOSTextInputOverlay, QIOSWindow, QIconEnginePlugin, QImageIOPlugin, QInputControl, QInputDevice, QInputDeviceManager, QInputMethod, QIosOptionalPlugin_NSPhotoLibrary, QItemSelectionModel, QItemSelectionModel, QKeyMapper, QLayout, QLibInputHandler, QLibInputKeyboard, QLibrary, QLocalServer, QMacPanGestureRecognizer, QMdi::ControlContainer, QMimeData, QMock1Plugin, QMock2Plugin, QMock3Plugin, QMock4Plugin, QMock5Plugin, QMock6Plugin, QModelListener, QMovie, QNetworkAccessBackend, QNetworkAccessBackendFactory, QNetworkAccessCache, QNetworkAccessManager, QNetworkConnectionMonitor, QNetworkCookieJar, QNetworkInformation, QNetworkInformationBackend, QNetworkInformationBackendFactory, QNonContiguousByteDevice, QObjectCleanupHandler, QObjectTableItem, QObjectTest::DeleteObject, QObjectTest::TestObject, QObjectUsingStandardAllocator, QObjectWithIncomplete, QOffscreenSurface, QOpenGLCompositor, QOpenGLContext, QOpenGLContextGroup, QOpenGLDebugLogger, QOpenGLEngineShaderManager, QOpenGLShader, QOpenGLShaderProgram, QOpenGLTimeMonitor, QOpenGLTimerQuery, QOpenGLVertexArrayObject, QPMCache, QPdfWriter, QPixmapFilter, QPlatformCursor, QPlatformDialogHelper, QPlatformGraphicsBuffer, QPlatformInputContext, QPlatformInputContextPlugin, QPlatformIntegrationPlugin, QPlatformMenu, QPlatformMenuBar, QPlatformMenuItem, QPlatformNativeInterface, QPlatformPrinterSupportPlugin, QPlatformSharedGraphicsCache, QPlatformSystemTrayIcon, QPlatformTextureList, QPlatformTextureListWatcher, QPlatformThemePlugin, QQnxAbstractNavigator, QQnxAbstractVirtualKeyboard, QQnxButtonEventNotifier, QQnxNavigatorEventHandler, QQnxNavigatorEventNotifier, QQnxScreen, QQnxScreenEventHandler, QScreen, QScroller, QScrollerPrivate, QSessionManager, QSettings, QSharedMemory, QShortcut, QSignalMapper, QSignalSpy, QSingleShotTimer, QSmSocketReceiver, QSocketNotifier, QSocks5BindStore, QSpiAccessibleBridge, QSpiApplicationAdaptor, QSpiDBusCache, QSqlDriver, QSqlDriverPlugin, QStyle, QStyleHints, QStylePlugin, QStyleSheetStyleCaches, QSyntaxHighlighter, QSystemTrayIcon, QSystemTrayWatcher, QTBUG48402_helper, QTBUG_2151::A, QTBUG_2151::B, QTBUG_35657::B, QT_BEGIN_NAMESPACE::ProtocolHandlerDeleter, QTcpServer, QTest::WatchDog, QTestEventLoop, QTextDocument, QTextImageHandler, QTextObject, QThread, QThreadPool, QTimeLine, QTimer, QTlsBackend, QTranslator, QTsLibMouseHandler, QTuioHandler, QUndoGroup, QUnifiedTimer, QValidator, QVncClient, QVncServer, QWasmClipboard, QWasmCompositor, QWasmEventTranslator, QWasmIntegration, QWasmScreen, QWhatsThisPrivate, QWidget, QWidgetAnimator, QWidgetBaselineTest, QWidgetResizeHandler, QWindow, QWindowsCaRootFetcher, QWindowsNativeDialogBase, QWindowsPipeReader, QWindowsPipeWriter, QWindowsRemovableDriveListener, QXcbBasicConnection, QXcbClipboardTransaction, QXcbGlIntegrationPlugin, QXcbSystemTrayTracker, Q_DECL_FINAL, Q_DECL_FINAL, QtBug13431Helper, QtBug27161Helper, QtCocoaInterruptDispatcher, QtDiag::EventFilter, QtTestCustomObject, QtTestObject, QtTestObject, QtTestObject, QtTestObject2, QtTestObject3, Qtbug14268Helper, QuitBlocker, QuitSpy, QuitTester, Quit_Object, RaceConditionSignalWaiter, RaceObject, RateControlledReader, RateController, Receiver, Receiver, ReceiverDisconnecting, ReceiverObject, RecurringTimerObject, RecursOnTimeoutAndStopTimerTimer, RecursiveObject, ReleasePlugin, RemovalObserver, RemoveTabObject, Renderer, Renderer, Responder, RestartedTimerFiresTooSoonObject, ResultObject, ReturnValue, ScreenReader, ScriptInterface, Scroller, SelectionObserver, SendPostedEventsTester, Sender, SenderObject, SenderObject, SenderWithSharedPointerConstQObject, Server, Server, ServerObject, Settings, ShowHideEventCounter, SignalArgumentChecker, SignalArgumentChecker, SignalReceiver, SignalReceiver, SignalReceiver, SignalReceiver, SignalReceiver, SignalReceiver, SignalRecorder, SignalSlotClass, SignalTest1, SignalTest2, SignalTest3, SignalTest4, SingleFunctionKeywordAfterInline, SingleFunctionKeywordBeforeInline, SingleFunctionKeywordBeforeReturnType, SingletonObject, SlippyMap, SlotRepeater, SlotsWithVoidTemplateTest, SlowReader, SlowSlotObject, SocketFactory, SocketPair, SocketPair, SomeHandler, SomeObject, SomeObject, SomeObject, SomeObject, SomeObject, SomeSingleton, SomethingOfEverything, Spy, StartValueTester, StaticPlugin, StaticSlotChecker, StatusChanger, StopableJob, StringLiterals, StringVariant, Subscription, SuperObject, SvgTextObject, Syncronizer, TabWidgetResetter, Task192552, Task87883, Test, Test, Test, Test1, TestBenchmark, TestBenchmark, TestCompiler, TestComponent, TestComponent, TestEventReceiver, TestFwdProperties, TestGui, TestGui, TestGui, TestInitResourcesStaticPlugin, TestObject, TestObject, TestObject, TestObject, TestPlugin, TestPluginMetaData, TestPointeeCanBeIncomplete, TestQPrivateSlots, TestQString, TestQString, TestQString, TestRunnable, TestStaticPlugin, TestStaticResourcePropagation, TestSyntaxHighlighter, TheOldPlugin, ThePlugin, Theme, ThreadObj, ThreadedEventReceiver, TimeoutCounter, TimerInfiniteRecursionObject, TimerReceiver, ToBeDeleted, ToBeDeleted, Tools, TorrentClient, Tracker, TrackerClient, TransferItem, TypeLazyRegistration, TypenameWithUnsigned, TypesTest1, TypesTest10, TypesTest11, TypesTest12, TypesTest13, TypesTest14, TypesTest15, TypesTest16, TypesTest17, TypesTest18, TypesTest19, TypesTest2, TypesTest20, TypesTest3, TypesTest4, TypesTest5, TypesTest6, TypesTest7, TypesTest8, TypesTest9, UndoRedoRecorder, UndoRedoRecorder, UnexpectedDisconnectTester, User, VirtualSlotsObjectBase, WaitForQMyServer, WaitForQMyServer, WinNewlines, WindowDumper, WindowTouchEventFilter, Worker, qfile_vs_qnetworkaccessmanager, qtimer_vs_qmetaobject, sealed, sealed, src_gui_opengl_qopengldebug::LogHandler, src_gui_opengl_qopengldebug::SnippetWrapper, src_gui_util_qdesktopservices::MyHelpHandler, task209485_ButtonDeleter, test_widgets_app_deployment, tst_Android, tst_Android, tst_Assert, tst_BadXml, tst_BenchlibCallgrind, tst_BenchlibCounting, tst_BenchlibEventCounter, tst_BenchlibOptions, tst_BenchlibTickCounter, tst_BenchlibWalltime, tst_Blacklisted, tst_Cmptest, tst_Collections, tst_ContainerApiSymmetry, tst_Counting, tst_Crashes, tst_DataTable, tst_DataTable, tst_DateTime, tst_DeleteLater, tst_DeleteLater_noApp, tst_DrawTexture, tst_Encoder, tst_Exception, tst_ExpectFail, tst_FailCleanup, tst_FailDataType, tst_FailFetchType, tst_FailInit, tst_FailInitData, tst_FetchBogus, tst_Gestures, tst_GraphicsViewBenchmark, tst_Http2, tst_InitMain, tst_JUnit, tst_Keyboard, tst_LanceBench, tst_Lancelot, tst_LargeFile, tst_LexGen, tst_LongString, tst_MacNativeEvents, tst_MacPlist, tst_ManualMultitouch, tst_Mouse, tst_NetworkRemoteStressTest, tst_NetworkSelfTest, tst_NetworkSelftest, tst_NetworkStressTest, tst_NoQtEventLoop, tst_Nothing, tst_OutFormat, tst_PairDiagnostics, tst_Parser, tst_Pass, tst_PlatformSocketEngine, tst_PrintDataTags, tst_PrintDataTagsWithGlobalTags, tst_QAbstractAnimation, tst_QAbstractButton, tst_QAbstractFileEngine, tst_QAbstractItemModel, tst_QAbstractItemModelTester, tst_QAbstractNetworkCache, tst_QAbstractPrintDialog, tst_QAbstractProxyModel, tst_QAbstractScrollArea, tst_QAbstractSocket, tst_QAbstractSpinBox, tst_QAbstractTextDocumentLayout, tst_QAccessibilityLinux, tst_QAccessibilityMac, tst_QAction, tst_QAction, tst_QActionGroup, tst_QActionGroup, tst_QAnimationGroup, tst_QAnyStringView, tst_QApplication, tst_QArrayData, tst_QAsn1Element, tst_QAtomicInt, tst_QAtomicIntegerXX, tst_QAtomicPointer, tst_QAuthenticator, tst_QBackingStore, tst_QBitArray, tst_QBrush, tst_QBuffer, tst_QButtonGroup, tst_QByteArray, tst_QByteArray, tst_QByteArrayApiSymmetry, tst_QByteArrayList, tst_QByteArrayMatcher, tst_QByteArrayView, tst_QByteDataBuffer, tst_QCache, tst_QCalendar, tst_QCalendarWidget, tst_QCborStreamReader, tst_QCborStreamWriter, tst_QCborValue, tst_QCborValue_Json, tst_QChar, tst_QChar, tst_QCheckBox, tst_QClipboard, tst_QCollator, tst_QColor, tst_QColor, tst_QColorDialog, tst_QColorSpace, tst_QColorTransform, tst_QColumnView, tst_QCommandLineParser, tst_QCommandLinkButton, tst_QCompare, tst_QComplexText, tst_QConcatenateTablesProxyModel, tst_QContiguousCache, tst_QContiguousCache, tst_QCoreApplication, tst_QCoreApplication, tst_QCryptographicHash, tst_QCryptographicHash, tst_QCssParser, tst_QCursor, tst_QDBusAbstractAdaptor, tst_QDBusAbstractInterface, tst_QDBusConnection, tst_QDBusConnectionNoBus, tst_QDBusConnectionNoBus, tst_QDBusConnection_Delayed, tst_QDBusContext, tst_QDBusInterface, tst_QDBusLocalCalls, tst_QDBusMarshall, tst_QDBusMetaObject, tst_QDBusMetaType, tst_QDBusPendingCall, tst_QDBusPendingReply, tst_QDBusPerformance, tst_QDBusReply, tst_QDBusServiceWatcher, tst_QDBusThreading, tst_QDBusType, tst_QDBusXmlParser, tst_QDataStream, tst_QDataStream, tst_QDataUrl, tst_QDataWidgetMapper, tst_QDate, tst_QDate, tst_QDateTime, tst_QDateTime, tst_QDateTimeEdit, tst_QDateTimeParser, tst_QDeadlineTimer, tst_QDebug, tst_QDecompressHelper, tst_QDecompressHelper, tst_QDesktopServices, tst_QDial, tst_QDialog, tst_QDialogButtonBox, tst_QDir, tst_QDirIterator, tst_QDirIterator, tst_QDir_10000, tst_QDir_tree, tst_QDnsLookup, tst_QDnsLookup_Appless, tst_QDockWidget, tst_QDom, tst_QDoubleSpinBox, tst_QDoubleValidator, tst_QDrag, tst_QDtls, tst_QDtlsCookie, tst_QDuplicateTracker, tst_QEasingCurve, tst_QEasingProperties, tst_QElapsedTimer, tst_QErrorMessage, tst_QEvent, tst_QEventDispatcher, tst_QEventLoop, tst_QExecStringList, tst_QExplicitlySharedDataPointer, tst_QFactoryLoader, tst_QFile, tst_QFileDialog2, tst_QFileIconProvider, tst_QFileInfo, tst_QFileInfo, tst_QFileSelector, tst_QFileSystemEntry, tst_QFileSystemMetaData, tst_QFileSystemModel, tst_QFileSystemWatcher, tst_QFiledialog, tst_QFlags, tst_QFlatMap, tst_QFocusEvent, tst_QFocusFrame, tst_QFont, tst_QFontCache, tst_QFontComboBox, tst_QFontDatabase, tst_QFontDialog, tst_QFontMetrics, tst_QFontMetrics, tst_QFrame, tst_QFreeList, tst_QFuture, tst_QFuture, tst_QFutureSynchronizer, tst_QGestureRecognizer, tst_QGetPutEnv, tst_QGlobal, tst_QGlobalStatic, tst_QGlyphRun, tst_QGraphicsAnchorLayout, tst_QGraphicsAnchorLayout, tst_QGraphicsAnchorLayout1, tst_QGraphicsEffect, tst_QGraphicsEffectSource, tst_QGraphicsGridLayout, tst_QGraphicsItem, tst_QGraphicsItem, tst_QGraphicsItemAnimation, tst_QGraphicsLayout, tst_QGraphicsLayout, tst_QGraphicsLayoutItem, tst_QGraphicsLinearLayout, tst_QGraphicsLinearLayout, tst_QGraphicsObject, tst_QGraphicsPixmapItem, tst_QGraphicsPolygonItem, tst_QGraphicsProxyWidget, tst_QGraphicsScene, tst_QGraphicsScene, tst_QGraphicsSceneIndex, tst_QGraphicsTransform, tst_QGraphicsView, tst_QGraphicsView, tst_QGraphicsWidget, tst_QGraphicsWidget, tst_QGroupBox, tst_QGuiMetaType, tst_QGuiMetaType, tst_QGuiVariant, tst_QGuiVariant, tst_QGuiVariantNoApplication, tst_QHash, tst_QHash, tst_QHashFunctions, tst_QHashSeed, tst_QHeaderView, tst_QHighDpi, tst_QHooks, tst_QHostAddress, tst_QHostInfo, tst_QHsts, tst_QHttpNetworkConnection, tst_QHttpNetworkReply, tst_QHttpSocketEngine, tst_QIODevice, tst_QIODevice, tst_QIcoImageFormat, tst_QIcon, tst_QIconHighDpi, tst_QIdentityProxyModel, tst_QImage, tst_QImageConversion, tst_QImageIOHandler, tst_QImageReader, tst_QImageReader, tst_QImageScale, tst_QImageWriter, tst_QInputControl, tst_QInputDevice, tst_QInputDialog, tst_QIntValidator, tst_QIpAddress, tst_QItemDelegate, tst_QItemEditorFactory, tst_QItemModel, tst_QItemSelectionModel, tst_QItemView, tst_QJniEnvironment, tst_QJniObject, tst_QKeyCombination, tst_QKeyEvent, tst_QKeySequence, tst_QKeySequenceEdit, tst_QLCDNumber, tst_QLabel, tst_QLatin1String, tst_QLibrary, tst_QLine, tst_QList, tst_QList, tst_QListView, tst_QListView, tst_QListWidget, tst_QLocalSocket, tst_QLocalSocket, tst_QLocale, tst_QLocale, tst_QLockFile, tst_QLogging, tst_QLoggingRegistry, tst_QMacAutoreleasePool, tst_QMacStyle, tst_QMainWindow, tst_QMakeArray, tst_QMap, tst_QMap, tst_QMargins, tst_QMath, tst_QMatrix4x4, tst_QMatrixNxN, tst_QMatrixNxN4x4Properties, tst_QMdiArea, tst_QMdiSubWindow, tst_QMessageAuthenticationCode, tst_QMessageBox, tst_QMessageLogger, tst_QMetaContainer, tst_QMetaEnum, tst_QMetaEnum, tst_QMetaMethod, tst_QMetaObject, tst_QMetaObject, tst_QMetaObjectBuilder, tst_QMetaProperty, tst_QMetaType, tst_QMetaType, tst_QMimeData, tst_QMimeDatabase, tst_QMimeDatabase, tst_QMouseEvent, tst_QMovie, tst_QMutex, tst_QMutex, tst_QMutexLocker, tst_QNetworkAccessManager, tst_QNetworkAccessManager_And_QProgressDialog, tst_QNetworkAddressEntry, tst_QNetworkCacheMetaData, tst_QNetworkCookie, tst_QNetworkCookieJar, tst_QNetworkDatagram, tst_QNetworkDiskCache, tst_QNetworkInformation, tst_QNetworkInformation_appless, tst_QNetworkInterface, tst_QNetworkProxy, tst_QNetworkProxyFactory, tst_QNetworkReply, tst_QNetworkRequest, tst_QNoDebug, tst_QNumeric, tst_QObject, tst_QObject, tst_QObjectRace, tst_QOcsp, tst_QOffsetStringArray, tst_QOpenGLWidget, tst_QOpenGLWindow, tst_QOpenGlConfig, tst_QOperatingSystemVersion, tst_QPageLayout, tst_QPageRanges, tst_QPageSize, tst_QPaintEngine, tst_QPainter, tst_QPainter, tst_QPainterPath, tst_QPainterPathStroker, tst_QPair, tst_QPalette, tst_QParallelAnimationGroup, tst_QPasswordDigestor, tst_QPathClipper, tst_QPauseAnimation, tst_QPdfWriter, tst_QPen, tst_QPicture, tst_QPixelFormat, tst_QPixmap, tst_QPixmap, tst_QPixmapCache, tst_QPixmapCache, tst_QPixmapFilter, tst_QPlainTextEdit, tst_QPlugin, tst_QPluginLoader, tst_QPoint, tst_QPointF, tst_QPointer, tst_QPolygon, tst_QPrintDevice, tst_QPrinter, tst_QPrinterInfo, tst_QProcess, tst_QProcess, tst_QProcessEnvironment, tst_QProcessNoApplication, tst_QProcess_and_GuiEventLoop, tst_QProgressBar, tst_QProgressDialog, tst_QPromise, tst_QProperty, tst_QProperty, tst_QPropertyAnimation, tst_QPushButton, tst_QQuaternion, tst_QQuaternion, tst_QQuaternionProperties, tst_QQueue, tst_QRadioButton, tst_QRasterWindow, tst_QRawFont, tst_QReadLocker, tst_QReadWriteLock, tst_QReadWriteLock, tst_QRect, tst_QRect, tst_QRegion, tst_QRegularExpression, tst_QRegularExpressionBenchmark, tst_QRegularExpressionValidator, tst_QResourceEngine, tst_QRhi, tst_QRingBuffer, tst_QRingBuffer, tst_QSaveFile, tst_QScopeGuard, tst_QScopedPointer, tst_QScopedValueRollback, tst_QScreen, tst_QScreen_Xrandr, tst_QScrollArea, tst_QScroller, tst_QSctpSocket, tst_QSequentialAnimationGroup, tst_QSet, tst_QSet, tst_QSettings, tst_QShader, tst_QSharedMemory, tst_QSharedPointer, tst_QSharedPointer, tst_QSharedPointer_and_QWidget, tst_QShortcut, tst_QShortcut, tst_QSidebar, tst_QSignalBlocker, tst_QSignalMapper, tst_QSignalSpy, tst_QSize, tst_QSizeF, tst_QSizeGrip, tst_QSizePolicy, tst_QSlider, tst_QSocketNotifier, tst_QSocks5SocketEngine, tst_QSortFilterProxyModel, tst_QSortFilterProxyModel, tst_QSortFilterProxyModelRegularExpression, tst_QSortFilterProxyModel_Recursive, tst_QSpinBox, tst_QSplashScreen, tst_QSplitter, tst_QSql, tst_QSqlDatabase, tst_QSqlDriver, tst_QSqlError, tst_QSqlField, tst_QSqlQuery, tst_QSqlQuery, tst_QSqlQueryModel, tst_QSqlRecord, tst_QSqlRecord, tst_QSqlRelationalDelegate, tst_QSqlRelationalTableModel, tst_QSqlResult, tst_QSqlTableModel, tst_QSqlThread, tst_QSslCertificate, tst_QSslCipher, tst_QSslDiffieHellmanParameters, tst_QSslEllipticCurve, tst_QSslError, tst_QSslKey, tst_QSslSocket, tst_QSslSocket, tst_QSslSocket, tst_QSslSocket_onDemandCertificates_member, tst_QSslSocket_onDemandCertificates_static, tst_QStack, tst_QStackedLayout, tst_QStackedWidget, tst_QStandardItem, tst_QStandardItemModel, tst_QStaticText, tst_QStatusBar, tst_QStl, tst_QStorageInfo, tst_QString, tst_QString, tst_QStringApiSymmetry, tst_QStringBuilder, tst_QStringBuilder1, tst_QStringBuilder2, tst_QStringBuilder3, tst_QStringBuilder4, tst_QStringConverter, tst_QStringIterator, tst_QStringList, tst_QStringList, tst_QStringListModel, tst_QStringMatcher, tst_QStringTokenizer, tst_QStringTokenizer, tst_QStringView, tst_QString_NoCastFromByteArray, tst_QStyleOption, tst_QSurfaceFormat, tst_QSyntaxHighlighter, tst_QSystemSemaphore, tst_QSystemTrayIcon, tst_QTabBar, tst_QTabWidget, tst_QTableView, tst_QTableView, tst_QTableWidget, tst_QTaggedPointer, tst_QTcpServer, tst_QTcpServer, tst_QTcpSocket, tst_QTemporaryDir, tst_QTemporaryFile, tst_QTemporaryFile, tst_QText, tst_QTextBlock, tst_QTextBoundaryFinder, tst_QTextBrowser, tst_QTextBrowser, tst_QTextCursor, tst_QTextDocument, tst_QTextDocument, tst_QTextDocumentFragment, tst_QTextDocumentLayout, tst_QTextEdit, tst_QTextFormat, tst_QTextImageHandler, tst_QTextLayout, tst_QTextList, tst_QTextMarkdownImporter, tst_QTextMarkdownWriter, tst_QTextObject, tst_QTextOdfWriter, tst_QTextPieceTable, tst_QTextScriptEngine, tst_QTextStream, tst_QTextStream, tst_QTextTable, tst_QThread, tst_QThreadOnce, tst_QThreadPool, tst_QThreadPool, tst_QThreadStorage, tst_QThreadStorage, tst_QTime, tst_QTimeLine, tst_QTimeZone, tst_QTimeZone, tst_QTimer, tst_QToolBar, tst_QToolBox, tst_QToolButton, tst_QToolTip, tst_QTouchEvent, tst_QTransform, tst_QTransform, tst_QTranslator, tst_QTransposeProxyModel, tst_QTreeWidget, tst_QTreeWidgetItemIterator, tst_QUdpSocket, tst_QUdpSocket, tst_QUndoGroup, tst_QUndoStack, tst_QUnicodeTools, tst_QUrl, tst_QUrl, tst_QUrlInternal, tst_QUrlQuery, tst_QUrlUts46, tst_QUuid, tst_QUuid, tst_QVarLengthArray, tst_QVariant, tst_QVariant, tst_QVariantAnimation, tst_QVector, tst_QVectorND, tst_QVectorNDProperties, tst_QVersionNumber, tst_QVulkan, tst_QWidget, tst_QWidget, tst_QWidgetMetaType, tst_QWidgetRepaintManager, tst_QWidgetsVariant, tst_QWinEventNotifier, tst_QWinEventNotifier, tst_QWinRegistry, tst_QWindow, tst_QWindowContainer, tst_QWizard, tst_QWriteLocker, tst_QX11Info, tst_QXmlStream, tst_QZip, tst_QtBench, tst_QtConcurrentMedian, tst_QtEndian, tst_QtJson, tst_SessionManagement_macOS, tst_Signaldumper, tst_Silent, tst_SingleSkip, tst_Skip, tst_SkipCleanup, tst_SkipInit, tst_SkipInitData, tst_Sleep, tst_StrCmp, tst_Subtest, tst_TestA, tst_TestB, tst_TestLib, tst_TupleDiagnostics, tst_VerifyExceptionThrown, tst_Warnings, tst_Watchdog, tst_XkbKeyboard, tst_associative_containers, tst_float, tst_globaldata, tst_jpeg, tst_languageChange, tst_macdeployqt, tst_qAddPostRoutine, tst_qAddPreRoutine, tst_q_func_info, tst_qanimation, tst_qapplication, tst_qapplicationstatic, tst_qdbuscpp2xml, tst_qdbusxml2cpp, tst_qdesktopservices, tst_qfile, tst_qfileopenevent, tst_qfloat16, tst_qhostinfo, tst_qhttpnetworkconnection, tst_qinputmethod, tst_qmake, tst_qmakelib, tst_qmessagehandler, tst_qmimetype, tst_qmouseevent_modal, tst_qnetworkdiskcache, tst_qnetworkreply, tst_qnetworkreply, tst_qnetworkreply_from_cache, tst_qregion, tst_qstandardpaths, tst_qstylesheetstyle, tst_qt_poll, tst_qtexturefilereader, tst_rcc, tst_toString, tst_toolsupport, tst_uic, tst_vector_vs_std, and tst_windeployqt.

Collaboration diagram for QObject:
Collaboration graph
[legend]

Public Slots

void deleteLater ()
 

Signals

void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 

Public Member Functions

Q_INVOKABLE QObject (QObject *parent=nullptr)
 
virtual ~QObject ()
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const
 
void setObjectName (const QString &name)
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const noexcept
 
bool blockSignals (bool b) noexcept
 
QThreadthread () const
 
void moveToThread (QThread *thread)
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 
template<typename T >
T findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
const QObjectListchildren () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 
void dumpObjectInfo () const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 
bool inherits (const char *classname) const
 

Static Public Member Functions

static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 

Protected Member Functions

QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 

Protected Attributes

QScopedPointer< QObjectDatad_ptr
 

Properties

QString objectName
 the name of this object More...
 

Friends

struct QMetaObject
 
struct QMetaObjectPrivate
 
class QMetaCallEvent
 
class QApplication
 
class QApplicationPrivate
 
class QCoreApplication
 
class QCoreApplicationPrivate
 
class QWidget
 
class QAccessibleWidget
 
class QThreadData
 

Related Functions

(Note that these are not member functions.)

template< class T > T qobject_cast (const QObject *object)
 
template< typename T > T qFindChildqFindChildren (const QObject *obj, const QString &name)()
 
template< typename T > QList< TqFindChildrenqFindChildren (const QObject *obj, const QString &name)()
 
 QObjectList
 

Detailed Description

The QObject class is the base class of all Qt objects.

\inmodule QtCore

\reentrant

QObject is the heart of the Qt \l{Object Model}. The central feature in this model is a very powerful mechanism for seamless object communication called \l{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.

QObjects organize themselves in \l {Object Trees & Ownership} {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().

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.

When an object is deleted, it emits a destroyed() signal. You can catch this signal to avoid dangling references to QObjects.

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.

Last but not least, QObject provides the basic timer support in Qt; see QTimer for high-level support for timers.

Notice that the Q_OBJECT macro is mandatory for any object that implements signals, slots or properties. You also need to run the \l{moc}{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.

All Qt widgets inherit QObject. The convenience function isWidgetType() returns whether an object is actually a widget. It is much faster than \l{qobject_cast()}{qobject_cast}<QWidget *>({obj}) or {obj}->\l{inherits()}{inherits}("QWidget").

Some QObject functions, e.g. children(), return a QObjectList. QObjectList is a typedef for QList<QObject *>.

Definition at line 124 of file qobject.h.

Constructor & Destructor Documentation

◆ QObject() [1/2]

QObject::QObject ( QObject parent = nullptr)
explicit

Constructs an object with parent object parent.

The parent of an object may be viewed as the object's owner. For instance, a \l{QDialog}{dialog box} is the parent of the \uicontrol{OK} and \uicontrol{Cancel} buttons it contains.

The destructor of a parent object destroys all child objects.

Setting parent to \nullptr constructs an object with no parent. If the object is a widget, it will become a top-level window.

See also
parent(), findChild(), findChildren()

Definition at line 913 of file qobject.cpp.

Here is the caller graph for this function:

◆ ~QObject()

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

Definition at line 983 of file qobject.cpp.

Here is the call graph for this function:

◆ QObject() [2/2]

QObject::QObject ( QObjectPrivate dd,
QObject parent = nullptr 
)
protected

Definition at line 921 of file qobject.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ bindableObjectName()

QBindable< QString > QObject::bindableObjectName ( )

Definition at line 1276 of file qobject.cpp.

◆ bindingStorage() [1/2]

QBindingStorage* QObject::bindingStorage ( )
inline

Definition at line 400 of file qobject.h.

◆ bindingStorage() [2/2]

const QBindingStorage* QObject::bindingStorage ( ) const
inline

Definition at line 401 of file qobject.h.

◆ blockSignals()

bool QObject::blockSignals ( bool  block)
noexcept

If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). If block is false, no such blocking will occur.

The return value is the previous value of signalsBlocked().

Note that the destroyed() signal will be emitted even if the signals for this object have been blocked.

Signals emitted while being blocked are not buffered.

See also
signalsBlocked(), QSignalBlocker

Definition at line 1514 of file qobject.cpp.

Here is the caller graph for this function:

◆ childEvent()

void QObject::childEvent ( QChildEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive child events. The event is passed in the event parameter.

QEvent::ChildAdded and QEvent::ChildRemoved events are sent to objects when children are added or removed. In both cases you can only rely on the child being a QObject, or if isWidgetType() returns true, a QWidget. (This is because, in the \l{QEvent::ChildAdded}{ChildAdded} case, the child is not yet fully constructed, and in the \l{QEvent::ChildRemoved}{ChildRemoved} case it might have been destructed already).

QEvent::ChildPolished events are sent to widgets when children are polished, or when polished children are added. If you receive a child polished event, the child's construction is usually completed. However, this is not guaranteed, and multiple polish events may be delivered during the execution of a widget's constructor.

For every child widget, you receive one \l{QEvent::ChildAdded}{ChildAdded} event, zero or more \l{QEvent::ChildPolished}{ChildPolished} events, and one \l{QEvent::ChildRemoved}{ChildRemoved} event.

The \l{QEvent::ChildPolished}{ChildPolished} event is omitted if a child is removed immediately after it is added. If a child is polished several times during construction and destruction, you may receive several child polished events for the same child, each time with a different virtual table.

See also
event()

Reimplemented in QGroupBox, QLayout, QMdiSubWindow, and QSplitter.

Definition at line 1437 of file qobject.cpp.

Here is the caller graph for this function:

◆ children()

const QObjectList & QObject::children ( ) const
inline

Returns a list of child objects. The QObjectList class is defined in the {<QObject>} header file as the following:

\quotefromfile kernel/qobject.h \skipto /typedef .*QObjectList/ \printuntil QObjectList

The first child added is the \l{QList::first()}{first} object in the list and the last child added is the \l{QList::last()}{last} object in the list, i.e. new children are appended at the end.

Note that the list order changes when QWidget children are \l{QWidget::raise()}{raised} or \l{QWidget::lower()}{lowered}. A widget that is raised becomes the last object in the list, and a widget that is lowered becomes the first object in the list.

See also
findChild(), findChildren(), parent(), setParent()

Definition at line 206 of file qobject.h.

Here is the caller graph for this function:

◆ connect() [1/8]

QMetaObject::Connection QObject::connect ( const QObject sender,
const char *  signal,
const char *  member,
Qt::ConnectionType  type = Qt::AutoConnection 
) const
inline

Definition at line 464 of file qobject.h.

Here is the call graph for this function:

◆ connect() [2/8]

QMetaObject::Connection QObject::connect ( const QObject sender,
const char *  signal,
const QObject receiver,
const char *  method,
Qt::ConnectionType  type = Qt::AutoConnection 
)
static

\threadsafe

Creates a connection of the given type from the signal in the sender object to the method in the receiver object. Returns a handle to the connection that can be used to disconnect it later.

You must use the SIGNAL() and SLOT() macros when specifying the signal and the method, for example:

This example ensures that the label always displays the current scroll bar value. Note that the signal and slots parameters must not contain any variable names, only the type. E.g. the following would not work and return false:

A signal can also be connected to another signal:

In this example, the MyWidget constructor relays a signal from a private member variable, and makes it available under a name that relates to MyWidget.

A signal can be connected to many slots and signals. Many signals can be connected to one slot.

If a signal is connected to several slots, the slots are activated in the same order in which the connections were made, when the signal is emitted.

The function returns a QMetaObject::Connection that represents a handle to a connection if it successfully connects the signal to the slot. The connection handle will be invalid if it cannot create the connection, for example, if QObject is unable to verify the existence of either signal or method, or if their signatures aren't compatible. You can check if the handle is valid by casting it to a bool.

By default, a signal is emitted for every connection you make; two signals are emitted for duplicate connections. You can break all of these connections with a single disconnect() call. If you pass the Qt::UniqueConnection type, the connection will only be made if it is not a duplicate. If there is already a duplicate (exact same signal to the exact same slot on the same objects), the connection will fail and connect will return an invalid QMetaObject::Connection.

Note
Qt::UniqueConnections do not work for lambdas, non-member functions and functors; they only apply to connecting to member functions.

The optional type parameter describes the type of connection to establish. In particular, it determines whether a particular signal is delivered to a slot immediately or queued for delivery at a later time. If the signal is queued, the parameters must be of types that are known to Qt's meta-object system, because Qt needs to copy the arguments to store them in an event behind the scenes. If you try to use a queued connection and get the error message

call qRegisterMetaType() to register the data type before you establish the connection.

See also
disconnect(), sender(), qRegisterMetaType(), Q_DECLARE_METATYPE(), {Differences between String-Based and Functor-Based Connections}

Definition at line 2772 of file qobject.cpp.

Here is the call graph for this function:

◆ connect() [3/8]

QMetaObject::Connection QObject::connect ( const QObject sender,
const QMetaMethod signal,
const QObject receiver,
const QMetaMethod method,
Qt::ConnectionType  type = Qt::AutoConnection 
)
static
Since
4.8

Creates a connection of the given type from the signal in the sender object to the method in the receiver object. Returns a handle to the connection that can be used to disconnect it later.

The Connection handle will be invalid if it cannot create the connection, for example, the parameters were invalid. You can check if the QMetaObject::Connection is valid by casting it to a bool.

This function works in the same way as {connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)} but it uses QMetaMethod to specify signal and method.

See also
connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)

Definition at line 2911 of file qobject.cpp.

Here is the call graph for this function:

◆ connect() [4/8]

static QMetaObject::Connection ::type QObject::connect ( const typename QtPrivate::FunctionPointer< Func1 >::Object sender,
Func1  signal,
const QObject context,
Func2  slot,
Qt::ConnectionType  type = Qt::AutoConnection 
)
inlinestatic

Definition at line 273 of file qobject.h.

Here is the call graph for this function:

◆ connect() [5/8]

template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer<Func2>::ArgumentCount == -1 && !std::is_convertible_v<Func2, const char*>, QMetaObject::Connection>::type QObject::connect ( const typename QtPrivate::FunctionPointer< Func1 >::Object sender,
Func1  signal,
const QObject context,
Func2  slot,
Qt::ConnectionType  type = Qt::AutoConnection 
)
inlinestatic

Definition at line 318 of file qobject.h.

Here is the call graph for this function:

◆ connect() [6/8]

template<typename Func1 , typename Func2 >
static QMetaObject::Connection QObject::connect ( const typename QtPrivate::FunctionPointer< Func1 >::Object sender,
Func1  signal,
const typename QtPrivate::FunctionPointer< Func2 >::Object receiver,
Func2  slot,
Qt::ConnectionType  type = Qt::AutoConnection 
)
inlinestatic

Definition at line 232 of file qobject.h.

Here is the call graph for this function:

◆ connect() [7/8]

static QMetaObject::Connection ::type QObject::connect ( const typename QtPrivate::FunctionPointer< Func1 >::Object sender,
Func1  signal,
Func2  slot 
)
inlinestatic

Definition at line 264 of file qobject.h.

Here is the call graph for this function:

◆ connect() [8/8]

template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer<Func2>::ArgumentCount == -1 && !std::is_convertible_v<Func2, const char*>, QMetaObject::Connection>::type QObject::connect ( const typename QtPrivate::FunctionPointer< Func1 >::Object sender,
Func1  signal,
Func2  slot 
)
inlinestatic

Definition at line 307 of file qobject.h.

Here is the call graph for this function:

◆ connectNotify()

void QObject::connectNotify ( const QMetaMethod signal)
protectedvirtual
Since
5.0

This virtual function is called when something has been connected to signal in this object.

If you want to compare signal with a specific signal, you can use QMetaMethod::fromSignal() as follows:

Warning
This function violates the object-oriented principle of modularity. However, it might be useful when you need to perform expensive initialization only if something is connected to a signal.
This function is called from the thread which performs the connection, which may be a different thread from the thread in which this object lives.
See also
connect(), disconnectNotify()

Reimplemented in ConnectByNameNotifySenderObject, NotifyObject, QDBusAbstractInterface, QFutureWatcherBase, QDBusConnectionInterface, and QBuffer.

Definition at line 3291 of file qobject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ customEvent()

void QObject::customEvent ( QEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive custom events. Custom events are user-defined events with a type value at least as large as the QEvent::User item of the QEvent::Type enum, and is typically a QEvent subclass. The event is passed in the event parameter.

See also
event(), QEvent

Reimplemented in QAndroidPlatformNativeInterface, DeliverInDefinedOrder::Object, tst_QEventLoop, TestEventReceiver, and MoveToThreadObject.

Definition at line 1451 of file qobject.cpp.

◆ deleteLater

void QObject::deleteLater ( )
slot

\threadsafe

Schedules this object for deletion.

The object will be deleted when control returns to the event loop. If the event loop is not running when this function is called (e.g. deleteLater() is called on an object before QCoreApplication::exec()), the object will be deleted once the event loop is started. If deleteLater() is called after the main event loop has stopped, the object will not be deleted. Since Qt 4.8, if deleteLater() is called on an object that lives in a thread with no running event loop, the object will be destroyed when the thread finishes.

Note that entering and leaving a new event loop (e.g., by opening a modal dialog) will not perform the deferred deletion; for the object to be deleted, the control must return to the event loop from which deleteLater() was called. This does not apply to objects deleted while a previous, nested event loop was still running: the Qt event loop will delete those objects as soon as the new nested event loop starts.

Note
It is safe to call this function more than once; when the first deferred deletion event is delivered, any pending events for the object are removed from the event queue.
See also
destroyed(), QPointer

Definition at line 2319 of file qobject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroyed

void QObject::destroyed ( QObject obj = nullptr)
signal

This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.

All the objects's children are destroyed immediately after this signal is emitted.

See also
deleteLater(), QPointer
Here is the caller graph for this function:

◆ disconnect() [1/7]

bool QObject::disconnect ( const char *  signal = nullptr,
const QObject receiver = nullptr,
const char *  member = nullptr 
) const
inline

Definition at line 351 of file qobject.h.

Here is the call graph for this function:

◆ disconnect() [2/7]

bool QObject::disconnect ( const QMetaObject::Connection connection)
static

Disconnect a connection.

If the connection is invalid or has already been disconnected, do nothing and return false.

See also
connect()

Definition at line 5101 of file qobject.cpp.

Here is the call graph for this function:

◆ disconnect() [3/7]

bool QObject::disconnect ( const QObject receiver,
const char *  member = nullptr 
) const
inline

Definition at line 354 of file qobject.h.

Here is the call graph for this function:

◆ disconnect() [4/7]

bool QObject::disconnect ( const QObject sender,
const char *  signal,
const QObject receiver,
const char *  method 
)
static

\threadsafe

Disconnects signal in object sender from method in object receiver. Returns true if the connection is successfully broken; otherwise returns false.

A signal-slot connection is removed when either of the objects involved are destroyed.

disconnect() is typically used in three ways, as the following examples demonstrate. \list 1

  • Disconnect everything connected to an object's signals:

equivalent to the non-static overloaded function

  • Disconnect everything connected to a specific signal:

equivalent to the non-static overloaded function

  • Disconnect a specific receiver:

equivalent to the non-static overloaded function

\endlist

\nullptr may be used as a wildcard, meaning "any signal", "any receiving object", or "any slot in the receiving object", respectively.

The sender may never be \nullptr. (You cannot disconnect signals from more than one object in a single call.)

If signal is \nullptr, it disconnects receiver and method from any signal. If not, only the specified signal is disconnected.

If receiver is \nullptr, it disconnects anything connected to signal. If not, slots in objects other than receiver are not disconnected.

If method is \nullptr, it disconnects anything that is connected to receiver. If not, only slots named method will be disconnected, and all other slots are left alone. The method must be \nullptr if receiver is left out, so you cannot disconnect a specifically-named slot on all objects.

disconnect-all

See also
connect()

Definition at line 3048 of file qobject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ disconnect() [5/7]

bool QObject::disconnect ( const QObject sender,
const QMetaMethod signal,
const QObject receiver,
const QMetaMethod method 
)
static
Since
4.8

Disconnects signal in object sender from method in object receiver. Returns true if the connection is successfully broken; otherwise returns false.

This function provides the same possibilities like {disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) } but uses QMetaMethod to represent the signal and the method to be disconnected.

Additionally this function returns false and no signals and slots disconnected if: \list 1

\li \a signal is not a member of sender class or one of its parent classes.

\li \a method is not a member of receiver class or one of its parent classes.

\li \a signal instance represents not a signal.

\endlist

QMetaMethod() may be used as wildcard in the meaning "any signal" or "any slot in receiving object". In the same way \nullptr can be used for receiver in the meaning "any receiving object". In this case method should also be QMetaMethod(). sender parameter should be never \nullptr.

disconnect-all

See also
disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)

Definition at line 3185 of file qobject.cpp.

Here is the call graph for this function:

◆ disconnect() [6/7]

template<typename Func1 >
static bool QObject::disconnect ( const typename QtPrivate::FunctionPointer< Func1 >::Object sender,
Func1  signal,
const QObject receiver,
void **  zero 
)
inlinestatic

Definition at line 380 of file qobject.h.

◆ disconnect() [7/7]

template<typename Func1 , typename Func2 >
static bool QObject::disconnect ( const typename QtPrivate::FunctionPointer< Func1 >::Object sender,
Func1  signal,
const typename QtPrivate::FunctionPointer< Func2 >::Object receiver,
Func2  slot 
)
inlinestatic

Definition at line 363 of file qobject.h.

◆ disconnectNotify()

void QObject::disconnectNotify ( const QMetaMethod signal)
protectedvirtual
Since
5.0

This virtual function is called when something has been disconnected from signal in this object.

See connectNotify() for an example of how to compare signal with a specific signal.

If all signals were disconnected from this object (e.g., the signal argument to disconnect() was \nullptr), disconnectNotify() is only called once, and the signal will be an invalid QMetaMethod (QMetaMethod::isValid() returns false).

Warning
This function violates the object-oriented principle of modularity. However, it might be useful for optimizing access to expensive resources.
This function is called from the thread which performs the disconnection, which may be a different thread from the thread in which this object lives. This function may also be called with a QObject internal mutex locked. It is therefore not allowed to re-enter any of any QObject functions from your reimplementation and if you lock a mutex in your reimplementation, make sure that you don't call QObject functions with that mutex held in other places or it will result in a deadlock.
See also
disconnect(), connectNotify()

Reimplemented in ConnectByNameNotifySenderObject, NotifyObject, QDBusAbstractInterface, QFutureWatcherBase, QDBusConnectionInterface, and QBuffer.

Definition at line 3326 of file qobject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dumpObjectInfo()

void QObject::dumpObjectInfo ( ) const

Dumps information about signal connections, etc. for this object to the debug output.

Note
Before Qt 5.9, this function was not const.
See also
dumpObjectTree()

Definition at line 4211 of file qobject.cpp.

◆ dumpObjectTree()

void QObject::dumpObjectTree ( ) const

Dumps a tree of children to the debug output.

Note
Before Qt 5.9, this function was not const.
See also
dumpObjectInfo()

Definition at line 4197 of file qobject.cpp.

Here is the call graph for this function:

◆ dynamicPropertyNames()

QList< QByteArray > QObject::dynamicPropertyNames ( ) const
Since
4.2

Returns the names of all properties that were dynamically added to the object using setProperty().

Definition at line 4147 of file qobject.cpp.

Here is the caller graph for this function:

◆ event()

bool QObject::event ( QEvent e)
virtual

This virtual function receives events to an object and should return true if the event e was recognized and processed.

The event() function can be reimplemented to customize the behavior of an object.

Make sure you call the parent event class implementation for all the events you did not handle.

Example:

See also
installEventFilter(), timerEvent(), QCoreApplication::sendEvent(), QCoreApplication::postEvent()

Reimplemented in EventTarget, TouchTestWidget, TextRenderer, Window, EventReportWidget, ScreenWatcherMainWindow, PhysicalSizeTest, UpdateWidget, TestWidget, TouchEventPropagationTestWidget, SubQGraphicsWidget, TouchWidget, ContextMenuWidget, ReuseCanceledGesturesWidget, GestureItem, GestureWidget, Window, tst_QTouchEventWidget, InputItem, MyApplication, Window, ProcessEventsOnlySendsQueuedEvents, ProcessEventsAlwaysSendsPostedEventsObject, GlobalPostedEventsCountObject, ThreadedEventReceiver, QToolBar, QSpinBox, QSlider, QScrollBar, QMdiSubWindow, QMainWindow, QGroupBox, QDockWidget, QDockWidgetTitleButton, QDialogButtonBox, QDateTimeEdit, QComboBox, QCalendarWidget, QAbstractSpinBox, QSystemTrayIcon, QWidget, QGraphicsWidget, QGraphicsSceneBspTreeIndex, QGraphicsScene, QGraphicsProxyWidget, QWizard, QVncClient, QEglFSKmsEventHost, QAndroidPlatformScreen, QFbScreen, QHostInfoResult, QPaintDeviceWindow, QFileSystemModel, MyApplication, QThread, QFutureWatcherBase, QEventLoop, QSettings, MyWidget, QVariantAnimation, QSequentialAnimationGroup, QPropertyAnimation, QParallelAnimationGroup, QAnimationGroup, QAbstractAnimation, SortingBox, TabletApplication, ScribbleArea, ImageWidget, OpenGLWindow, RasterWindow, RasterWindow, TouchWidget, Slider, GestureImageItem, Widget, TabletWidget, FocusWidget, FocusChangeWindow, QWindowContainer, QGraphicsObject, MyClass, HelloWindow, RenderWindow, EventTester, PingPong, MyWidget, tst_QScrollerWidget, EventWindow, ChangeEventWindow, OverrideCountingWidget, SendPostedEventsTester, TestGraphicsWidget, NoConsumeWidgetBug13501, EventWindow, InputTestWindow, BlockableWindow, LiveLockTester, DynamicPropertyObject, tst_QEventDispatcher, EventGenerator, QWidgetTextControl, QToolButton, QToolBox, QToolBarExtension, QStackedWidget, QSplashScreen, QRubberBand, QRadioButton, QPushButton, QProgressBar, QLCDNumber, QLabel, QFrame, QFontComboBox, QFocusFrame, QDial, QCalendarPopup, QCommandLinkButton, QCheckBox, QAbstractSlider, QAbstractButton, QProxyStyle, QMessageBox, QXcbConnection, QOpenGLWidget, QShortcut, QEventDispatcherWin32, QWindowsPipeWriter, QWindowsPipeReader, QPauseAnimation, ListObject, PathStrokeRenderer, SlowWidget, AbstractViewItem, AbstractScrollArea, AbstractItemView, AbstractItemContainer, QMacStyle, src_gui_vulkan_qvulkaninstance2::VulkanWindow, PreviewDialog, PreviewWidget, Window, Window, Window, QTabWidget, QTabBar, QStatusBar, QSplitterHandle, QSplitter, QSizeGrip, QMenuBar, QMenu, QLineEdit, QKeySequenceEdit, QSystemTrayIconSys, QCompleter, QWidgetWindow, QWidgetAction, QApplication, QExceptionNotifier, QWriteNotifier, QReadNotifier, QNetworkReplyImpl, QWindow, QGuiApplication, QAction, QSocketNotifier, QCoreApplication, and RasterWindow.

Definition at line 1329 of file qobject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventFilter()

bool QObject::eventFilter ( QObject watched,
QEvent event 
)
virtual

Filters events if this object has been installed as an event filter for the watched object.

In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.

Example:

Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.

Some events, such as \l QEvent::ShortcutOverride must be explicitly accepted (by calling \l {QEvent::}{accept()} on them) in order to prevent propagation.

Warning
If you delete the receiver object in this function, be sure to return true. Otherwise, Qt will forward the event to the deleted object and the program might crash.
See also
installEventFilter()

Reimplemented in ShowHideEventCounter, EventCounterSpy, EventSpy< T >, EventSpy< T >, EventSpy< T >, EventSpy2, EventSpy< T >, QCalendarWidget, QPixmapStyle, QGraphicsScene, DemoController, EventSpy< T >, EventSpy< T >, EventSpy< T >, TestItemDelegate, EventLogger, SubQGraphicsProxyWidget, EventSpy< T >, QMdiSubWindow, QStyledItemDelegate, QItemDelegate, QGraphicsProxyWidget, QFontDialog, FilterObject, LanguageChooser, HoverPoints, WindowTouchEventFilter, tst_QTranslator, QIOSMenu, QSpiApplicationAdaptor, KeyPressEater, AbstractItemContainer, ExpectedEventList, MainWindow, GSuggestCompletion, TabletWidget, InteractiveWidget, EventFilter, PlatformWindowFilter, QuitSpy, QWidgetResizeHandler, QComboBoxPrivateContainer, QCompleter, QXcbDrag, QBasicDrag, ControllerWidget, EventFilter, ProximityEventFilter, EventSpy< T >, EventSpy< T >, QuitBlocker, EventSpy< T >, QWindowContainer, EventFilter, QtDiag::EventFilter, QSizeGrip, QMenuBar, QFocusFrame, QAlphaWidget, QWidgetAction, QWhatsThisPrivate, QTipLabel, QDialog, BaseWindowControl, BaseWindowControl, and MainWindow.

Definition at line 1484 of file qobject.cpp.

Here is the caller graph for this function:

◆ findChild()

template<typename T >
template< typename T > T * QObject::findChild ( const QString name = QString(),
Qt::FindChildOptions  options = Qt::FindChildrenRecursively 
) const
inline

Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned. In that case, findChildren() should be used.

This example returns a child {QPushButton} of {parentWidget} named {"button1"}, even if the button isn't a direct child of the parent:

This example returns a {QListWidget} child of {parentWidget}:

This example returns a child {QPushButton} of {parentWidget} (its direct parent) named {"button1"}:

This example returns a {QListWidget} child of {parentWidget}, its direct parent:

See also
findChildren()

Definition at line 168 of file qobject.h.

Here is the caller graph for this function:

◆ findChildren() [1/2]

template<typename T >
template< typename T > QList< T > QObject::findChildren ( const QString name,
Qt::FindChildOptions  options = Qt::FindChildrenRecursively 
) const
inline

Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. A null name argument causes all objects to be matched, an empty one only those whose objectName is empty. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

The following example shows how to find a list of child {QWidget}s of the specified {parentWidget} named {widgetname}:

This example returns all {QPushButton}s that are children of {parentWidget}:

This example returns all {QPushButton}s that are immediate children of {parentWidget}:

See also
findChild()

Definition at line 175 of file qobject.h.

Here is the caller graph for this function:

◆ findChildren() [2/2]

template<typename T >
template< typename T > QList< T > QObject::findChildren ( Qt::FindChildOptions  options = Qt::FindChildrenRecursively) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
6.3

Returns all children of this object that can be cast to type T, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

See also
findChild()

Definition at line 185 of file qobject.h.

◆ inherits()

bool QObject::inherits ( const char *  className) const
inline

Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.

A class is considered to inherit itself.

Example:

If you need to determine whether an object is an instance of a particular class for the purpose of casting it, consider using qobject_cast<Type *>(object) instead.

See also
metaObject(), qobject_cast()

Definition at line 411 of file qobject.h.

Here is the caller graph for this function:

◆ installEventFilter()

void QObject::installEventFilter ( QObject filterObj)

Installs an event filter filterObj on this object. For example:

An event filter is an object that receives all events that are sent to this object. The filter can either stop the event or forward it to this object. The event filter filterObj receives events via its eventFilter() function. The eventFilter() function must return true if the event should be filtered, (i.e. stopped); otherwise it must return false.

If multiple event filters are installed on a single object, the filter that was installed last is activated first.

Here's a KeyPressEater class that eats the key presses of its monitored objects:

And here's how to install it on two widgets:

The QShortcut class, for example, uses this technique to intercept shortcut key presses.

Warning
If you delete the receiver object in your eventFilter() function, be sure to return true. If you return false, Qt sends the event to the deleted object and the program will crash.

Note that the filtering object must be in the same thread as this object. If filterObj is in a different thread, this function does nothing. If either filterObj or this object are moved to a different thread after calling this function, the event filter will not be called until both objects have the same thread affinity again (it is not removed).

See also
removeEventFilter(), eventFilter(), event()

Definition at line 2235 of file qobject.cpp.

Here is the caller graph for this function:

◆ isSignalConnected()

bool QObject::isSignalConnected ( const QMetaMethod signal) const
protected
Since
5.0 Returns true if the signal is connected to at least one receiver, otherwise returns false.

signal must be a signal member of this object, otherwise the behaviour is undefined.

As the code snippet above illustrates, you can use this function to avoid emitting a signal that nobody listens to.

Warning
This function violates the object-oriented principle of modularity. However, it might be useful when you need to perform expensive initialization only if something is connected to a signal.

Definition at line 2613 of file qobject.cpp.

Here is the call graph for this function:

◆ isWidgetType()

bool QObject::isWidgetType ( ) const
inline

Returns true if the object is a widget; otherwise returns false.

Calling this function is equivalent to calling {inherits("QWidget")}, except that it is much faster.

Definition at line 148 of file qobject.h.

Here is the caller graph for this function:

◆ isWindowType()

bool QObject::isWindowType ( ) const
inline

Returns true if the object is a window; otherwise returns false.

Calling this function is equivalent to calling {inherits("QWindow")}, except that it is much faster.

Definition at line 149 of file qobject.h.

Here is the caller graph for this function:

◆ killTimer()

void QObject::killTimer ( int  id)

Kills the timer with timer identifier, id.

The timer identifier is returned by startTimer() when a timer event is started.

See also
timerEvent(), startTimer()

Definition at line 1838 of file qobject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ moveToThread()

void QObject::moveToThread ( QThread targetThread)

Changes the thread affinity for this object and its children. The object cannot be moved if it has a parent. Event processing will continue in the targetThread.

To move an object to the main thread, use QApplication::instance() to retrieve a pointer to the current application, and then use QApplication::thread() to retrieve the thread in which the application lives. For example:

If targetThread is \nullptr, all event processing for this object and its children stops, as they are no longer associated with any thread.

Note that all active timers for the object will be reset. The timers are first stopped in the current thread and restarted (with the same interval) in the targetThread. As a result, constantly moving an object between threads can postpone timer events indefinitely.

A QEvent::ThreadChange event is sent to this object just before the thread affinity is changed. You can handle this event to perform any special processing. Note that any new events that are posted to this object will be handled in the targetThread, provided it is not \nullptr: when it is \nullptr, no event processing for this object or its children can happen, as they are no longer associated with any thread.

Warning
This function is not thread-safe; the current thread must be same as the current thread affinity. In other words, this function can only "push" an object from the current thread to another thread, it cannot "pull" an object from any arbitrary thread to the current thread. There is one exception to this rule however: objects with no thread affinity can be "pulled" to the current thread.
See also
thread()

Definition at line 1572 of file qobject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ objectName()

QString QObject::objectName ( ) const

Definition at line 1243 of file qobject.cpp.

Here is the call graph for this function:

◆ objectNameChanged

void QObject::objectNameChanged ( const QString objectName,
QPrivateSignal   
)
signal

This signal is emitted after the object's name has been changed. The new object name is passed as objectName.

See also
QObject::objectName
Here is the caller graph for this function:

◆ parent()

QObject * QObject::parent ( ) const
inline

Returns a pointer to the parent object.

See also
children()

Definition at line 409 of file qobject.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ property()

QVariant QObject::property ( const char *  name) const

Returns the value of the object's name property.

If no such property exists, the returned variant is invalid.

Information about all available properties is provided through the metaObject() and dynamicPropertyNames().

See also
setProperty(), QVariant::isValid(), metaObject(), dynamicPropertyNames()

Definition at line 4118 of file qobject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ receivers()

int QObject::receivers ( const char *  signal) const
protected

Returns the number of receivers connected to the signal.

Since both slots and signals can be used as receivers for signals, and the same connections can be made many times, the number of receivers is the same as the number of connections made from this signal.

When calling this function, you can use the SIGNAL() macro to pass a specific signal:

Warning
This function violates the object-oriented principle of modularity. However, it might be useful when you need to perform expensive initialization only if something is connected to a signal.
See also
isSignalConnected()

Definition at line 2554 of file qobject.cpp.

Here is the call graph for this function:

◆ removeEventFilter()

void QObject::removeEventFilter ( QObject obj)

Removes an event filter object obj from this object. The request is ignored if such an event filter has not been installed.

All event filters for this object are automatically removed when this object is destroyed.

It is always safe to remove an event filter, even during event filter activation (i.e. from the eventFilter() function).

See also
installEventFilter(), eventFilter(), event()

Definition at line 2267 of file qobject.cpp.

Here is the caller graph for this function:

◆ sender()

QObject * QObject::sender ( ) const
protected

Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. The pointer is valid only during the execution of the slot that calls this function from this object's thread context.

The pointer returned by this function becomes invalid if the sender is destroyed, or if the slot is disconnected from the sender's signal.

Warning
This function violates the object-oriented principle of modularity. However, getting access to the sender might be useful when many signals are connected to a single slot.
As mentioned above, the return value of this function is not valid when the slot is called via a Qt::DirectConnection from a thread different from this object's thread. Do not use this function in this type of scenario.
See also
senderSignalIndex()

Definition at line 2472 of file qobject.cpp.

Here is the caller graph for this function:

◆ senderSignalIndex()

int QObject::senderSignalIndex ( ) const
protected
Since
4.8

Returns the meta-method index of the signal that called the currently executing slot, which is a member of the class returned by sender(). If called outside of a slot activated by a signal, -1 is returned.

For signals with default parameters, this function will always return the index with all parameters, regardless of which was used with connect(). For example, the signal {destroyed(QObject *obj = \nullptr)} will have two different indexes (with and without the parameter), but this function will always return the index with a parameter. This does not apply when overloading signals with different parameters.

Warning
This function violates the object-oriented principle of modularity. However, getting access to the signal index might be useful when many signals are connected to a single slot.
The return value of this function is not valid when the slot is called via a Qt::DirectConnection from a thread different from this object's thread. Do not use this function in this type of scenario.
See also
sender(), QMetaObject::indexOfSignal(), QMetaObject::method()

Definition at line 2514 of file qobject.cpp.

Here is the caller graph for this function:

◆ setObjectName()

void QObject::setObjectName ( const QString name)

Definition at line 1261 of file qobject.cpp.

Here is the caller graph for this function:

◆ setParent()

void QObject::setParent ( QObject parent)

Makes the object a child of parent.

See also
parent(), children()

Definition at line 2108 of file qobject.cpp.

Here is the caller graph for this function:

◆ setProperty()

bool QObject::setProperty ( const char *  name,
const QVariant value 
)

Sets the value of the object's name property to value.

If the property is defined in the class using Q_PROPERTY then true is returned on success and false otherwise. If the property is not defined using Q_PROPERTY, and therefore not listed in the meta-object, it is added as a dynamic property and false is returned.

Information about all available properties is provided through the metaObject() and dynamicPropertyNames().

Dynamic properties can be queried again using property() and can be removed by setting the property value to an invalid QVariant. Changing the value of a dynamic property causes a QDynamicPropertyChangeEvent to be sent to the object.

{Note:} Dynamic properties starting with "_q_" are reserved for internal purposes.

See also
property(), metaObject(), dynamicPropertyNames(), QMetaProperty::write()

Definition at line 4063 of file qobject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ signalsBlocked()

bool QObject::signalsBlocked ( ) const
inlinenoexcept

Returns true if signals are blocked; otherwise returns false.

Signals are not blocked by default.

See also
blockSignals(), QSignalBlocker

Definition at line 151 of file qobject.h.

Here is the caller graph for this function:

◆ startTimer()

int QObject::startTimer ( int  interval,
Qt::TimerType  timerType = Qt::CoarseTimer 
)

Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.

A timer event will occur every interval milliseconds until killTimer() is called. If interval is 0, then the timer event occurs once every time there are no more window system events to process.

The virtual timerEvent() function is called with the QTimerEvent event parameter class when a timer event occurs. Reimplement this function to get timer events.

If multiple timers are running, the QTimerEvent::timerId() can be used to find out which timer was activated.

Example:

Note that QTimer's accuracy depends on the underlying operating system and hardware. The timerType argument allows you to customize the accuracy of the timer. See Qt::TimerType for information on the different timer types. Most platforms support an accuracy of 20 milliseconds; some provide more. If Qt is unable to deliver the requested number of timer events, it will silently discard some.

The QTimer class provides a high-level programming interface with single-shot timers and timer signals instead of events. There is also a QBasicTimer class that is more lightweight than QTimer and less clumsy than using timer IDs directly.

See also
timerEvent(), killTimer(), QTimer::singleShot()
Since
5.9 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.

A timer event will occur every time interval until killTimer() is called. If time is equal to {std::chrono::duration::zero()}, then the timer event occurs once every time there are no more window system events to process.

The virtual timerEvent() function is called with the QTimerEvent event parameter class when a timer event occurs. Reimplement this function to get timer events.

If multiple timers are running, the QTimerEvent::timerId() can be used to find out which timer was activated.

Example:

Note that QTimer's accuracy depends on the underlying operating system and hardware. The timerType argument allows you to customize the accuracy of the timer. See Qt::TimerType for information on the different timer types. Most platforms support an accuracy of 20 milliseconds; some provide more. If Qt is unable to deliver the requested number of timer events, it will silently discard some.

The QTimer class provides a high-level programming interface with single-shot timers and timer signals instead of events. There is also a QBasicTimer class that is more lightweight than QTimer and less clumsy than using timer IDs directly.

See also
timerEvent(), killTimer(), QTimer::singleShot()

Definition at line 1765 of file qobject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ thread()

QThread * QObject::thread ( ) const

Returns the thread in which the object lives.

See also
moveToThread()

Definition at line 1527 of file qobject.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ timerEvent()

void QObject::timerEvent ( QTimerEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive timer events for the object.

QTimer provides a higher-level interface to the timer functionality, and also more general information about timers. The timer event is passed in the event parameter.

See also
startTimer(), killTimer(), event()

Reimplemented in RecurringTimerObject, TimerInfiniteRecursionObject, QMdiSubWindow, QComboBoxPrivateContainer, Connection, ExecCloseHelper, LiveLockTester, DragWidget, ToolDialog, ClientServer, TimerReceiver, UncontrolledAnimation, UncontrolledAnimation, QWidgetLineControl, QTabBar, QAbstractSpinBox, QQnxScreenEventHandler, QSocks5BindStore, QFileSystemModel, QTimeLine, MyObject, WigglyWidget, TetrixBoard, Mouse, TrackerClient, PeerWireClient, ItemMover, FlickableTicker, Controller, Car, RestartedTimerFiresTooSoonObject, QMacPanGestureRecognizer, QXcbClipboardTransaction, SubMenuPositionExecMenu, QWidgetTextControl, QMainWindowLayout, QComboBoxPrivateScroller, QAbstractButton, QBalloonTip, PressDelayHandler, QTipLabel, QTestEventLoop, QXcbDrag, QCocoaMenu, QTextDocumentLayout, QDBusConnectionPrivate, QDefaultAnimationDriver, PathStrokeRenderer, PathDeformRenderer, XFormView, MainWidget, EventReportWidget, ScreenDisplayer, ScreenDisplayer, MainWindow, CMainWindowTimer, CToolBarTimer, ViewportCrashWidget, CloseWidget, TestApplication, CustomScene, RateControlledReader, DontBlockEvents, MoveToThreadObject, QToolButton, QMenuBar, QMenu, QLineEdit, QKeySequenceEdit, QAbstractSlider, QTreeModel, QWindowsDialogHelperBase< QPlatformFileDialogHelper >, QNetworkAccessCache, QPMCache, QTimer, QSingleShotTimer, QUnifiedTimer, CompositionRenderer, Window, AnalogClockWindow, MouseStatWidget, MyObject, Window, Raycasting, LightMaps, and DigiFlip.

Definition at line 1399 of file qobject.cpp.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ QAccessibleWidget

friend class QAccessibleWidget
friend

Definition at line 446 of file qobject.h.

◆ QApplication

friend class QApplication
friend

Definition at line 441 of file qobject.h.

◆ QApplicationPrivate

friend class QApplicationPrivate
friend

Definition at line 442 of file qobject.h.

◆ QCoreApplication

friend class QCoreApplication
friend

Definition at line 443 of file qobject.h.

◆ QCoreApplicationPrivate

friend class QCoreApplicationPrivate
friend

Definition at line 444 of file qobject.h.

◆ qFindChildqFindChildren()

template< typename T > T qFindChildqFindChildren ( const QObject obj,
const QString name 
)
related
Deprecated:

This function is equivalent to {obj}->\l{QObject::findChild()}{findChild}<T>(name).

Note
This function was provided as a workaround for MSVC 6 which did not support member template functions. It is advised to use the other form in new code.
See also
QObject::findChild()

◆ qFindChildrenqFindChildren()

template< typename T > QList< T > qFindChildrenqFindChildren ( const QObject obj,
const QString name 
)
related
Deprecated:

This function is equivalent to {obj}->\l{QObject::findChildren()}{findChildren}<T>(name).

Note
This function was provided as a workaround for MSVC 6 which did not support member template functions. It is advised to use the other form in new code.
See also
QObject::findChildren()

◆ QMetaCallEvent

friend class QMetaCallEvent
friend

Definition at line 440 of file qobject.h.

◆ QMetaObject

friend struct QMetaObject
friend

Definition at line 438 of file qobject.h.

◆ QMetaObjectPrivate

friend struct QMetaObjectPrivate
friend

Definition at line 439 of file qobject.h.

◆ qobject_cast()

template< class T > T qobject_cast ( const QObject object)
related

Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. If object is \nullptr then it will also return \nullptr.

The class T must inherit (directly or indirectly) QObject and be declared with the \l Q_OBJECT macro.

A class is considered to inherit itself.

Example:

The qobject_cast() function behaves similarly to the standard C++ dynamic_cast(), with the advantages that it doesn't require RTTI support and it works across dynamic library boundaries.

qobject_cast() can also be used in conjunction with interfaces; see the \l{tools/plugandpaint/app}{Plug & Paint} example for details.

Warning
If T isn't declared with the Q_OBJECT macro, this function's return value is undefined.
See also
QObject::inherits()

Definition at line 478 of file qobject.h.

◆ QObjectList()

QObjectList
related

\macro Q_CLASSINFO(Name, Value)

This macro associates extra information to the class, which is available using QObject::metaObject(). Qt makes only limited use of this feature in \l{Qt D-Bus} and \l{Qt QML} modules.

The extra information takes the form of a Name string and a Value literal string.

Example:

See also
QMetaObject::classInfo()
{Using Qt D-Bus Adaptors}
{Extending QML}

\macro Q_INTERFACES(...)

This macro tells Qt which interfaces the class implements. This is used when implementing plugins.

Example:

\dots

See the \l{tools/plugandpaint/plugins/basictools}{Plug & Paint Basic Tools} example for details.

See also
Q_DECLARE_INTERFACE(), Q_PLUGIN_METADATA(), {How to Create Qt Plugins}

\macro Q_PROPERTY(...)

This macro is used for declaring properties in classes that inherit QObject. Properties behave like class data members, but they have additional features accessible through the \l {Meta-Object System}.

The property name and type and the READ function are required. The type can be any type supported by QVariant, or it can be a user-defined type. The other items are optional, but a WRITE function is common. The attributes default to true except USER, which defaults to false.

For example:

For more details about how to use this macro, and a more detailed example of its use, see the discussion on \l {Qt's Property System}.

See also
{Qt's Property System}

\macro Q_ENUMS(...)

Deprecated:

In new code, you should prefer the use of the Q_ENUM() macro, which makes the type available also to the meta type system. For instance, QMetaEnum::fromType() will not work with types declared with Q_ENUMS().

This macro registers one or several enum types to the meta-object system.

If you want to register an enum that is declared in another class, the enum must be fully qualified with the name of the class defining it. In addition, the class defining the enum has to inherit QObject as well as declare the enum using Q_ENUMS().

See also
{Qt's Property System}

\macro Q_FLAGS(...)

Deprecated:

This macro registers one or several \l{QFlags}{flags types} with the meta-object system. It is typically used in a class definition to declare that values of a given enum can be used as flags and combined using the bitwise OR operator.

Note
This macro takes care of registering individual flag values with the meta-object system, so it is unnecessary to use Q_ENUMS() in addition to this macro.

In new code, you should prefer the use of the Q_FLAG() macro, which makes the type available also to the meta type system.

See also
{Qt's Property System}

\macro Q_ENUM(...)

Since
5.5

This macro registers an enum type with the meta-object system. It must be placed after the enum declaration in a class that has the Q_OBJECT, Q_GADGET or Q_GADGET_EXPORT macro. For namespaces use \l Q_ENUM_NS() instead.

For example:

Enumerations that are declared with Q_ENUM have their QMetaEnum registered in the enclosing QMetaObject. You can also use QMetaEnum::fromType() to get the QMetaEnum.

Registered enumerations are automatically registered also to the Qt meta type system, making them known to QMetaType without the need to use Q_DECLARE_METATYPE(). This will enable useful features; for example, if used in a QVariant, you can convert them to strings. Likewise, passing them to QDebug will print out their names.

Mind that the enum values are stored as signed int in the meta object system. Registering enumerations with values outside the range of values valid for int will lead to overflows and potentially undefined behavior when accessing them through the meta object system. QML, for example, does access registered enumerations through the meta object system.

See also
{Qt's Property System}

\macro Q_FLAG(...)

Since
5.5

This macro registers a single \l{QFlags}{flags type} with the meta-object system. It is typically used in a class definition to declare that values of a given enum can be used as flags and combined using the bitwise OR operator. For namespaces use \l Q_FLAG_NS() instead.

The macro must be placed after the enum declaration. The declaration of the flags type is done using the \l Q_DECLARE_FLAGS() macro.

For example, in QItemSelectionModel, the \l{QItemSelectionModel::SelectionFlags}{SelectionFlags} flag is declared in the following way:

Note
The Q_FLAG macro takes care of registering individual flag values with the meta-object system, so it is unnecessary to use Q_ENUM() in addition to this macro.
See also
{Qt's Property System}

\macro Q_ENUM_NS(...)

Since
5.8

This macro registers an enum type with the meta-object system. It must be placed after the enum declaration in a namespace that has the Q_NAMESPACE macro. It is the same as \l Q_ENUM but in a namespace.

Enumerations that are declared with Q_ENUM_NS have their QMetaEnum registered in the enclosing QMetaObject. You can also use QMetaEnum::fromType() to get the QMetaEnum.

Registered enumerations are automatically registered also to the Qt meta type system, making them known to QMetaType without the need to use Q_DECLARE_METATYPE(). This will enable useful features; for example, if used in a QVariant, you can convert them to strings. Likewise, passing them to QDebug will print out their names.

Mind that the enum values are stored as signed int in the meta object system. Registering enumerations with values outside the range of values valid for int will lead to overflows and potentially undefined behavior when accessing them through the meta object system. QML, for example, does access registered enumerations through the meta object system.

See also
{Qt's Property System}

\macro Q_FLAG_NS(...)

Since
5.8

This macro registers a single \l{QFlags}{flags type} with the meta-object system. It is used in a namespace that has the Q_NAMESPACE macro, to declare that values of a given enum can be used as flags and combined using the bitwise OR operator. It is the same as \l Q_FLAG but in a namespace.

The macro must be placed after the enum declaration.

Note
The Q_FLAG_NS macro takes care of registering individual flag values with the meta-object system, so it is unnecessary to use Q_ENUM_NS() in addition to this macro.
See also
{Qt's Property System}

\macro Q_OBJECT

The Q_OBJECT macro must appear in the private section of a class definition that declares its own signals and slots or that uses other services provided by Qt's meta-object system.

For example:

\codeline

Note
This macro requires the class to be a subclass of QObject. Use Q_GADGET or Q_GADGET_EXPORT instead of Q_OBJECT to enable the meta object system's support for enums in a class that is not a QObject subclass.
See also
{Meta-Object System}, {Signals and Slots}, {Qt's Property System}

\macro Q_GADGET

The Q_GADGET macro is a lighter version of the Q_OBJECT macro for classes that do not inherit from QObject but still want to use some of the reflection capabilities offered by QMetaObject. Just like the Q_OBJECT macro, it must appear in the private section of a class definition.

Q_GADGETs can have Q_ENUM, Q_PROPERTY and Q_INVOKABLE, but they cannot have signals or slots.

Q_GADGET makes a class member, {staticMetaObject}, available. {staticMetaObject} is of type QMetaObject and provides access to the enums declared with Q_ENUMS.

See also
Q_GADGET_EXPORT

\macro Q_GADGET_EXPORT(EXPORT_MACRO)

Since
6.3

The Q_GADGET_EXPORT macro works exactly like the Q_GADGET macro. However, the {staticMetaObject} variable that is made available (see Q_GADGET) is declared with the supplied EXPORT_MACRO qualifier. This is useful if the object needs to be exported from a dynamic library, but the enclosing class as a whole should not be (e.g. because it consists of mostly inline functions).

For example:

class Point {
Q_PROPERTY(int x MEMBER x)
Q_PROPERTY(int y MEMBER y)
~~~
#define EXPORT_MACRO
GLint GLint GLint GLint GLint x
[0]
GLint y
#define Q_PROPERTY(...)
Definition: qtmetamacros.h:92
#define Q_GADGET_EXPORT(...)
Definition: qtmetamacros.h:179
Definition: main.cpp:253
See also
Q_GADGET, {Creating Shared Libraries}

\macro Q_NAMESPACE

Since
5.8

The Q_NAMESPACE macro can be used to add QMetaObject capabilities to a namespace.

Q_NAMESPACEs can have Q_CLASSINFO, Q_ENUM_NS, Q_FLAG_NS, but they cannot have Q_ENUM, Q_FLAG, Q_PROPERTY, Q_INVOKABLE, signals nor slots.

Q_NAMESPACE makes an external variable, {staticMetaObject}, available. {staticMetaObject} is of type QMetaObject and provides access to the enums declared with Q_ENUM_NS/Q_FLAG_NS.

For example:

namespace test {
...
typing.Tuple[int, int] test(str binary_directory, *debug=False)
#define Q_NAMESPACE
Definition: qtmetamacros.h:202
See also
Q_NAMESPACE_EXPORT

\macro Q_NAMESPACE_EXPORT(EXPORT_MACRO)

Since
5.14

The Q_NAMESPACE_EXPORT macro can be used to add QMetaObject capabilities to a namespace.

It works exactly like the Q_NAMESPACE macro. However, the external {staticMetaObject} variable that gets defined in the namespace is declared with the supplied EXPORT_MACRO qualifier. This is useful if the object needs to be exported from a dynamic library.

For example:

namespace test {
...
#define Q_NAMESPACE_EXPORT(...)
Definition: qtmetamacros.h:196
See also
Q_NAMESPACE, {Creating Shared Libraries}

\macro Q_MOC_INCLUDE

Since
6.0

The Q_MOC_INCLUDE macro can be used within or outside a class, and tell the \l{moc}{Meta Object Compiler} to add an include.

// Put this in your code and the generated code will include this header.
Q_MOC_INCLUDE("myheader.h")
#define Q_MOC_INCLUDE(...)
Definition: qtmetamacros.h:115

This is useful if the types you use as properties or signal/slots arguments are forward declared.

\macro Q_SIGNALS

Use this macro to replace the signals keyword in class declarations, when you want to use Qt Signals and Slots with a \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}.

The macro is normally used when no_keywords is specified with the CONFIG variable in the .pro file, but it can be used even when no_keywords is not specified.

\macro Q_SIGNAL

This is an additional macro that allows you to mark a single function as a signal. It can be quite useful, especially when you use a 3rd-party source code parser which doesn't understand a signals or Q_SIGNALS groups.

Use this macro to replace the signals keyword in class declarations, when you want to use Qt Signals and Slots with a \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}.

The macro is normally used when no_keywords is specified with the CONFIG variable in the .pro file, but it can be used even when no_keywords is not specified.

\macro Q_SLOTS

Use this macro to replace the slots keyword in class declarations, when you want to use Qt Signals and Slots with a \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}.

The macro is normally used when no_keywords is specified with the CONFIG variable in the .pro file, but it can be used even when no_keywords is not specified.

\macro Q_SLOT

This is an additional macro that allows you to mark a single function as a slot. It can be quite useful, especially when you use a 3rd-party source code parser which doesn't understand a slots or Q_SLOTS groups.

Use this macro to replace the slots keyword in class declarations, when you want to use Qt Signals and Slots with a \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}.

The macro is normally used when no_keywords is specified with the CONFIG variable in the .pro file, but it can be used even when no_keywords is not specified.

\macro Q_EMIT

Use this macro to replace the emit keyword for emitting signals, when you want to use Qt Signals and Slots with a \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}.

The macro is normally used when no_keywords is specified with the CONFIG variable in the .pro file, but it can be used even when no_keywords is not specified.

\macro Q_INVOKABLE

Apply this macro to declarations of member functions to allow them to be invoked via the meta-object system. The macro is written before the return type, as shown in the following example:

The invokableMethod() function is marked up using Q_INVOKABLE, causing it to be registered with the meta-object system and enabling it to be invoked using QMetaObject::invokeMethod(). Since normalMethod() function is not registered in this way, it cannot be invoked using QMetaObject::invokeMethod().

If an invokable member function returns a pointer to a QObject or a subclass of QObject and it is invoked from QML, special ownership rules apply. See \l{qtqml-cppintegration-data.html}{Data Type Conversion Between QML and C++} for more information.

\macro Q_REVISION

Apply this macro to declarations of member functions to tag them with a revision number in the meta-object system. The macro is written before the return type, as shown in the following example:

This is useful when using the meta-object system to dynamically expose objects to another API, as you can match the version expected by multiple versions of the other API. Consider the following simplified example:

Using the same Window class as the previous example, the newProperty and newMethod would only be exposed in this code when the expected version is {2.1} or greater.

Since all methods are considered to be in revision {0} if untagged, a tag of {Q_REVISION(0)} or {Q_REVISION(0, 0)} is invalid and ignored.

You can pass one or two integer parameters to {Q_REVISION}. If you pass one parameter, it denotes the minor version only. This means that the major version is unspecified. If you pass two, the first parameter is the major version and the second parameter is the minor version.

This tag is not used by the meta-object system itself. Currently this is only used by the QtQml module.

For a more generic string tag, see \l QMetaMethod::tag()

See also
QMetaMethod::revision()

\macro Q_SET_OBJECT_NAME(Object)

Since
5.0

This macro assigns Object the objectName "Object".

It doesn't matter whether Object is a pointer or not, the macro figures that out by itself.

See also
QObject::objectName()

\macro QT_NO_NARROWING_CONVERSIONS_IN_CONNECT

Since
5.8

Defining this macro will disable narrowing and floating-point-to-integral conversions between the arguments carried by a signal and the arguments accepted by a slot, when the signal and the slot are connected using the PMF-based syntax.

See also
QObject::connect

Synonym for QList<QObject *>.

Definition at line 82 of file qobject.h.

◆ QThreadData

friend class QThreadData
friend

Definition at line 447 of file qobject.h.

◆ QWidget

friend class QWidget
friend

Definition at line 445 of file qobject.h.

Member Data Documentation

◆ d_ptr

QScopedPointer<QObjectData> QObject::d_ptr
protected

Definition at line 436 of file qobject.h.

Property Documentation

◆ objectName

QObject::objectName
readwrite

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

By default, this property contains an empty string.

See also
metaObject(), QMetaObject::className()

Definition at line 117 of file qobject.h.


The documentation for this class was generated from the following files: