PySide6.QtCore.QObject¶
- class QObject¶
- The - QObjectclass is the base class of all Qt objects. More…- Inherited by: - QWidget,- QWizardPage,- QToolBar,- QTabWidget,- QTabBar,- QStatusBar,- QSplitterHandle,- QSplashScreen,- QSizeGrip,- QRubberBand,- QRhiWidget,- QProgressBar,- QMenuBar,- QMenu,- QMdiSubWindow,- QMainWindow,- QLineEdit,- QKeySequenceEdit,- QGroupBox,- QFrame,- QToolBox,- QStackedWidget,- QSplitter,- QLabel,- QLCDNumber,- QAbstractScrollArea,- QTextEdit,- QTextBrowser,- QScrollArea,- QPlainTextEdit,- QMdiArea,- QGraphicsView,- QAbstractItemView,- QTreeView,- QTreeWidget,- QHelpContentWidget,- QTableView,- QTableWidget,- QListView,- QUndoView,- QListWidget,- QHelpIndexWidget,- QHeaderView,- QColumnView,- QPdfView,- QFocusFrame,- QDockWidget,- QDialogButtonBox,- QDialog,- QWizard,- QProgressDialog,- QMessageBox,- QInputDialog,- QFontDialog,- QErrorMessage,- QColorDialog,- QPrintPreviewDialog,- QPageSetupDialog,- QAbstractPrintDialog,- QPrintDialog,- QComboBox,- QFontComboBox,- QCalendarWidget,- QAbstractSpinBox,- QSpinBox,- QDoubleSpinBox,- QDateTimeEdit,- QTimeEdit,- QDateEdit,- QAbstractSlider,- QSlider,- QScrollBar,- QDial,- QAbstractButton,- QToolButton,- QRadioButton,- QPushButton,- QCommandLinkButton,- QCheckBox,- QSvgWidget,- QQuickWidget,- QPrintPreviewWidget,- QPdfPageSelector,- QOpenGLWidget,- QVideoWidget,- QHelpSearchResultWidget,- QHelpSearchQueryWidget,- QHelpFilterSettingsWidget,- QDesignerWidgetBoxInterface,- QDesignerPropertyEditorInterface,- QDesignerObjectInspectorInterface,- QDesignerFormWindowInterface,- QDesignerActionEditorInterface,- QSystemTrayIcon,- QStyle,- QCommonStyle,- QProxyStyle,- QScroller,- QLayout,- QStackedLayout,- QGridLayout,- QFormLayout,- QBoxLayout,- QVBoxLayout,- QHBoxLayout,- QGraphicsTransform,- QGraphicsScale,- QGraphicsRotation,- QGraphicsScene,- QGraphicsObject,- QGraphicsWidget,- QGraphicsProxyWidget,- QGraphicsTextItem,- QGraphicsSvgItem,- QGraphicsVideoItem,- QGraphicsItemAnimation,- QGraphicsEffect,- QGraphicsOpacityEffect,- QGraphicsDropShadowEffect,- QGraphicsColorizeEffect,- QGraphicsBlurEffect,- QGraphicsAnchor,- QGesture,- QTapGesture,- QTapAndHoldGesture,- QSwipeGesture,- QPinchGesture,- QPanGesture,- QDataWidgetMapper,- QCompleter,- QButtonGroup,- QAbstractItemDelegate,- QStyledItemDelegate,- QItemDelegate,- QMaskGenerator,- QQuickWebEngineProfile,- QWebEngineWebAuthUxRequest,- QWebEngineUrlSchemeHandler,- QWebEngineUrlRequestJob,- QWebEngineUrlRequestInterceptor,- QWebEngineProfile,- QWebEngineNotification,- QWebEngineNewWindowRequest,- QWebEngineNavigationRequest,- QWebEngineHistory,- QWebEngineDownloadRequest,- QWebEngineContextMenuRequest,- QWebEngineClientHints,- QWebChannelAbstractTransport,- QWebChannel,- QUiLoader,- QTextToSpeechEngine,- QTextToSpeech,- QAbstractItemModelTester,- QSvgRenderer,- QAbstractTransition,- QSignalTransition,- QEventTransition,- QMouseEventTransition,- QKeyEventTransition,- QAbstractState,- QState,- QStateMachine,- QHistoryState,- QFinalState,- QSqlDriver,- QSpatialSound,- QAudioRoom,- QAudioListener,- QAudioEngine,- QAmbientSound,- QModbusReply,- QModbusDevice,- QModbusServer,- QModbusTcpServer,- QModbusRtuSerialServer,- QModbusClient,- QModbusTcpClient,- QModbusRtuSerialClient,- QCanBusDevice,- QCanBus,- QSensorReading,- QTiltReading,- QTapReading,- QRotationReading,- QProximityReading,- QPressureReading,- QOrientationReading,- QMagnetometerReading,- QLightReading,- QLidReading,- QIRProximityReading,- QHumidityReading,- QGyroscopeReading,- QCompassReading,- QAmbientTemperatureReading,- QAmbientLightReading,- QAccelerometerReading,- QSensorBackend,- QSensor,- QTiltSensor,- QTapSensor,- QRotationSensor,- QProximitySensor,- QPressureSensor,- QOrientationSensor,- QMagnetometer,- QLightSensor,- QLidSensor,- QIRProximitySensor,- QHumiditySensor,- QGyroscope,- QCompass,- QAmbientTemperatureSensor,- QAmbientLightSensor,- QAccelerometer,- QScxmlStateMachine,- QScxmlInvokableServiceFactory,- QScxmlStaticScxmlServiceFactory,- QScxmlDynamicScxmlServiceFactory,- QScxmlInvokableService,- QScxmlDataModel,- QScxmlNullDataModel,- QScxmlCppDataModel,- QtROIoDeviceBase,- QtROServerIoDevice,- QtROClientIoDevice,- QRemoteObjectReplica,- QRemoteObjectRegistry,- QRemoteObjectDynamicReplica,- QRemoteObjectPendingCallWatcher,- QRemoteObjectNode,- QRemoteObjectAbstractPersistedStore,- QRemoteObjectSettingsStore,- QConnectionAbstractServer,- QQuickAttachedPropertyPropagator,- QQuick3DObject,- QQuick3DTextureData,- QQuick3DRenderExtension,- QQuick3DInstancing,- QQuick3DGeometry,- QSGTextureProvider,- QSGTexture,- QSGDynamicTexture,- QQuickTransform,- QQuickTextureFactory,- QQuickTextDocument,- QQuickRenderControl,- QQuickItemGrabResult,- QQuickItem,- QQuickRhiItem,- QQuickPaintedItem,- QQuickFramebufferObject,- QQuickImageResponse,- QQmlPropertyMap,- QQmlImageProviderBase,- QQuickImageProvider,- QQuickAsyncImageProvider,- QQmlFileSelector,- QQmlExtensionPlugin,- QQmlExpression,- QQmlContext,- QQmlComponent,- QJSEngine,- QQmlEngine,- QGeoSatelliteInfoSource,- QNmeaSatelliteInfoSource,- QGeoPositionInfoSource,- QNmeaPositionInfoSource,- QGeoAreaMonitorSource,- QPdfPageRenderer,- QPdfPageNavigator,- QPdfDocument,- QOpenGLVertexArrayObject,- QOpenGLTimerQuery,- QOpenGLTimeMonitor,- QOpenGLShaderProgram,- QOpenGLShader,- QOpenGLDebugLogger,- QOpcUaProvider,- QOpcUaPlugin,- QOpcUaNode,- QOpcUaKeyPair,- QOpcUaHistoryReadResponse,- QOpcUaGenericStructHandler,- QOpcUaClient,- QNearFieldTarget,- QNearFieldManager,- QAbstractOAuthReplyHandler,- QOAuthOobReplyHandler,- QOAuthUriSchemeReplyHandler,- QRestAccessManager,- QNetworkInformation,- QNetworkCookieJar,- QNetworkAccessManager,- QLocalServer,- QHttpMultiPart,- QDtlsClientVerifier,- QDnsLookup,- QAbstractNetworkCache,- QNetworkDiskCache,- QWindowCapture,- QVideoSink,- QVideoFrameInput,- QSoundEffect,- QScreenCapture,- QMediaRecorder,- QMediaDevices,- QMediaCaptureSession,- QImageCapture,- QCamera,- QAudioSource,- QAudioSink,- QAudioOutput,- QAudioInput,- QAudioDecoder,- QAudioBufferOutput,- QAudioBufferInput,- QMqttSubscription,- QPlaceReply,- QPlaceSearchSuggestionReply,- QPlaceSearchReply,- QPlaceMatchReply,- QPlaceIdReply,- QPlaceDetailsReply,- QPlaceContentReply,- QPlaceManagerEngine,- QPlaceManager,- QGeoServiceProvider,- QGeoRoutingManagerEngine,- QGeoRoutingManager,- QGeoRouteReply,- QGeoCodingManagerEngine,- QGeoCodingManager,- QGeoCodeReply,- QAbstractHttpServer,- QHttpServer,- QHelpSearchEngineCore,- QHelpSearchEngine,- QHelpFilterEngine,- QHelpEngineCore,- QHelpEngine,- QWindow,- QQuickWindow,- QQuickView,- QPaintDeviceWindow,- QOpenGLWindow,- QRasterWindow,- QValidator,- QRegularExpressionValidator,- QIntValidator,- QDoubleValidator,- QUndoStack,- QUndoGroup,- QTextObject,- QTextFrame,- QTextTable,- QTextBlockGroup,- QTextList,- QTextDocument,- QSyntaxHighlighter,- QStyleHints,- QShortcut,- QSessionManager,- QScreen,- QPdfWriter,- QOpenGLContextGroup,- QOpenGLContext,- QOffscreenSurface,- QInputMethod,- QInputDevice,- QPointingDevice,- QDrag,- QClipboard,- QActionGroup,- QAction,- QWidgetAction,- QAbstractTextDocumentLayout,- QPlainTextDocumentLayout,- Q3DGraphsWidgetItem,- Q3DSurfaceWidgetItem,- Q3DScatterWidgetItem,- Q3DBarsWidgetItem,- QXYModelMapper,- QValue3DAxisFormatter,- QLogValue3DAxisFormatter,- QPieSlice,- QPieModelMapper,- QGraphsTheme,- QCustom3DItem,- QCustom3DVolume,- QCustom3DLabel,- QBarSet,- QBarModelMapper,- QAbstractSeries,- QXYSeries,- QScatterSeries,- QLineSeries,- QSplineSeries,- QPieSeries,- QAreaSeries,- QAbstractDataProxy,- QSurfaceDataProxy,- QItemModelSurfaceDataProxy,- QHeightMapSurfaceDataProxy,- QScatterDataProxy,- QItemModelScatterDataProxy,- QBarDataProxy,- QItemModelBarDataProxy,- QAbstractAxis,- QValueAxis,- QDateTimeAxis,- QBarCategoryAxis,- QAbstract3DSeries,- QSurface3DSeries,- QScatter3DSeries,- QBar3DSeries,- QAbstract3DAxis,- QValue3DAxis,- QCategory3DAxis,- Q3DScene,- QExtensionManager,- QDesignerFormWindowToolInterface,- QDesignerFormWindowManagerInterface,- QDesignerFormEditorInterface,- QDBusVirtualObject,- QDBusServiceWatcher,- QDBusServer,- QDBusPendingCallWatcher,- QDBusAbstractInterfaceBase,- QDBusAbstractInterface,- QDBusInterface,- QDBusConnectionInterface,- QDBusAbstractAdaptor,- QTranslator,- QTimer,- QTimeLine,- QSocketNotifier,- QSignalMapper,- QSharedMemory,- QSettings,- QPluginLoader,- QMimeData,- QLibrary,- QItemSelectionModel,- QIODevice,- QSerialPort,- QNetworkReply,- QLocalSocket,- QAbstractSocket,- QUdpSocket,- QTcpSocket,- QWebSocketServer,- QOAuthHttpServerReplyHandler,- QTcpServer,- QSslServer,- QWaveDecoder,- QProcess,- QFutureWatcherBase,- QFutureWatcher,- QFileSystemWatcher,- QFileSelector,- QFileDevice,- QSaveFile,- QFile,- QTemporaryFile,- QEventLoop,- QThreadPool,- QThread,- QCoreApplication,- QGuiApplication,- QApplication,- QWebSocket,- QAbstractOAuth,- QOAuth1,- QAbstractOAuth2,- QOAuth2AuthorizationCodeFlow,- QSslSocket,- QDtls,- QMqttClient,- QMovie,- QFileDialog,- QWebEngineView,- QWebEnginePage,- QWebEngineCookieStore,- QRemoteObjectHostBase,- QRemoteObjectRegistryHost,- QRemoteObjectHost,- QQmlApplicationEngine,- QMediaPlayer,- QBuffer,- QAbstractItemModel,- QFileSystemModel,- QAbstractItemModelReplica,- QPdfBookmarkModel,- QHelpContentModel,- QStandardItemModel,- QConcatenateTablesProxyModel,- QAbstractTableModel,- QSqlQueryModel,- QSqlTableModel,- QSqlRelationalTableModel,- QAbstractProxyModel,- QTransposeProxyModel,- QSortFilterProxyModel,- QIdentityProxyModel,- QAbstractListModel,- QWebEngineHistoryModel,- QPdfSearchModel,- QPdfLinkModel,- QStringListModel,- QHelpIndexModel,- QAbstractEventDispatcher,- QAbstractAnimation,- QVariantAnimation,- QPropertyAnimation,- QPauseAnimation,- QAnimationGroup,- QSequentialAnimationGroup,- QParallelAnimationGroup,- QFutureWatcherVoid,- QFutureWatcherQString,- QCoapReply,- QCoapResourceDiscoveryReply,- QCoapClient,- QVXYModelMapper,- QVPieModelMapper,- QVBarModelMapper,- QLogValueAxis,- QLegendMarker,- QXYLegendMarker,- QPieLegendMarker,- QLegend,- QHXYModelMapper,- QHPieModelMapper,- QHBarModelMapper,- QColorAxis,- QChartView,- QChart,- QPolarChart,- QCategoryAxis,- QCandlestickSet,- QCandlestickSeries,- QCandlestickModelMapper,- QVCandlestickModelMapper,- QHCandlestickModelMapper,- QCandlestickLegendMarker,- QBoxSet,- QBoxPlotSeries,- QBoxPlotModelMapper,- QVBoxPlotModelMapper,- QHBoxPlotModelMapper,- QBoxPlotLegendMarker,- QBarLegendMarker,- QAreaLegendMarker,- QAbstractBarSeries,- QBarSeries,- QStackedBarSeries,- QPercentBarSeries,- QHorizontalStackedBarSeries,- QHorizontalPercentBarSeries,- QHorizontalBarSeries,- QLowEnergyService,- QLowEnergyController,- QBluetoothSocket,- QBluetoothServiceDiscoveryAgent,- QBluetoothLocalDevice,- QBluetoothDeviceDiscoveryAgent,- QBluetoothServer,- QTextureWrapMode,- QStencilTestArguments,- QStencilOperationArguments,- QRenderCaptureReply,- QRenderCapabilities,- QPickEvent,- QPickTriangleEvent,- QPickPointEvent,- QPickLineEvent,- QGraphicsApiFilter,- QWheelEvent,- QMouseEvent,- QKeyEvent,- Qt3DWindow,- QNode,- QTechnique,- QShaderProgramBuilder,- QShaderProgram,- QShaderImage,- QRenderTargetOutput,- QRenderState,- QStencilTest,- QStencilOperation,- QStencilMask,- QSeamlessCubemap,- QScissorTest,- QRasterMode,- QPolygonOffset,- QPointSize,- QNoDepthMask,- QMultiSampleAntiAliasing,- QLineWidth,- QFrontFace,- QDithering,- QDepthTest,- QDepthRange,- QCullFace,- QColorMask,- QClipPlane,- QBlendEquationArguments,- QBlendEquation,- QAlphaTest,- QAlphaCoverage,- QRenderPass,- QPickingSettings,- QParameter,- QFrameGraphNode,- QWaitFence,- QViewport,- QTechniqueFilter,- QForwardRenderer,- QSubtreeEnabler,- QSortPolicy,- QSetFence,- QRenderTargetSelector,- QRenderSurfaceSelector,- QRenderStateSet,- QRenderPassFilter,- QRenderCapture,- QProximityFilter,- QNoPicking,- QNoDraw,- QMemoryBarrier,- QLayerFilter,- QFrustumCulling,- QDispatchCompute,- QDebugOverlay,- QClearBuffers,- QCameraSelector,- QBufferCapture,- QBlitFramebuffer,- QFilterKey,- QEffect,- QAbstractTextureImage,- QTextureImage,- QPaintedTextureImage,- QAbstractTexture,- QTextureRectangle,- QTextureLoader,- QTextureCubeMapArray,- QTextureCubeMap,- QTextureBuffer,- QTexture3D,- QTexture2DMultisampleArray,- QTexture2DMultisample,- QTexture2DArray,- QTexture2D,- QTexture1DArray,- QTexture1D,- QSharedGLTexture,- QAxisSetting,- QAxis,- QAction,- QAbstractPhysicalDevice,- QMouseDevice,- QKeyboardDevice,- QAbstractAxisInput,- QButtonAxisInput,- QAnalogAxisInput,- QAbstractActionInput,- QInputSequence,- QInputChord,- QActionInput,- QSpriteSheetItem,- QAbstractSpriteSheet,- QSpriteSheet,- QSpriteGrid,- QJoint,- QGeometryView,- QTorusGeometryView,- QSphereGeometryView,- QPlaneGeometryView,- QCylinderGeometryView,- QCuboidGeometryView,- QConeGeometryView,- QGeometry,- QTorusGeometry,- QSphereGeometry,- QPlaneGeometry,- QExtrudedTextGeometry,- QCylinderGeometry,- QCuboidGeometry,- QConeGeometry,- QEntity,- QCamera,- QText2DEntity,- QSkyboxEntity,- QAbstractCameraController,- QOrbitCameraController,- QFirstPersonCameraController,- QComponent,- QShaderData,- QSceneLoader,- QRenderTarget,- QRenderSettings,- QObjectPicker,- QMaterial,- QTextureMaterial,- QPhongMaterial,- QPhongAlphaMaterial,- QPerVertexColorMaterial,- QNormalDiffuseSpecularMapMaterial,- QNormalDiffuseMapMaterial,- QNormalDiffuseMapAlphaMaterial,- QMorphPhongMaterial,- QMetalRoughMaterial,- QGoochMaterial,- QDiffuseSpecularMaterial,- QDiffuseSpecularMapMaterial,- QDiffuseMapMaterial,- QLevelOfDetail,- QLevelOfDetailSwitch,- QLayer,- QEnvironmentLight,- QComputeCommand,- QCameraLens,- QAbstractRayCaster,- QScreenRayCaster,- QRayCaster,- QAbstractLight,- QSpotLight,- QPointLight,- QDirectionalLight,- QFrameAction,- QMouseHandler,- QLogicalDevice,- QKeyboardHandler,- QInputSettings,- QAxisAccumulator,- QTransform,- QCoreSettings,- QBuffer,- QBoundingVolume,- QPickingProxy,- QGeometryRenderer,- QMesh,- QTorusMesh,- QSphereMesh,- QPlaneMesh,- QExtrudedTextMesh,- QCylinderMesh,- QCuboidMesh,- QConeMesh,- QAttribute,- QAspectEngine,- QArmature,- QAbstractSkeleton,- QSkeletonLoader,- QSkeleton,- QAbstractAspect,- QRenderAspect,- QLogicAspect,- QInputAspect,- QCoreAspect,- QMorphTarget,- QClock,- QChannelMapper,- QAnimationGroup,- QAnimationController,- QAnimationAspect,- QAbstractClipBlendNode,- QLerpClipBlend,- QClipBlendValue,- QAdditiveClipBlend,- QAbstractClipAnimator,- QClipAnimator,- QBlendedClipAnimator,- QAbstractChannelMapping,- QSkeletonMapping,- QChannelMapping,- QCallbackMapping,- QAbstractAnimationClip,- QAnimationClipLoader,- QAnimationClip,- QAbstractAnimation,- QVertexBlendAnimation,- QMorphingAnimation,- QKeyframeAnimation- Synopsis¶- Properties¶- objectNameᅟ- The name of this object
 - Methods¶- def - __init__()
- def - blockSignals()
- def - children()
- def - connect()
- def - disconnect()
- def - dumpObjectInfo()
- def - dumpObjectTree()
- def - emit()
- def - findChild()
- def - findChildren()
- def - inherits()
- def - isWidgetType()
- def - isWindowType()
- def - killTimer()
- def - moveToThread()
- def - objectName()
- def - parent()
- def - property()
- def - receivers()
- def - sender()
- def - setObjectName()
- def - setParent()
- def - setProperty()
- def - signalsBlocked()
- def - startTimer()
- def - thread()
- def - tr()
 - Virtual methods¶- def - childEvent()
- def - connectNotify()
- def - customEvent()
- def - event()
- def - eventFilter()
- def - metaObject()
- def - timerEvent()
 - Slots¶- def - deleteLater()
 - Signals¶- def - destroyed()
 - Static functions¶- def - connect()
- def - disconnect()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- QObjectis the heart of the Qt Object Model . The central feature in this model is a very powerful mechanism for seamless object communication called signals and slots . You can connect a signal to a slot with- connect()and destroy the connection with- disconnect(). To avoid never ending notification loops you can temporarily block signals with- blockSignals(). The protected functions- connectNotify()and- disconnectNotify()make it possible to track connections.- QObjects organize themselves in object trees . When you create a - QObjectwith 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- className()). You can determine whether the object’s class inherits another class in the- QObjectinheritance 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, - QObjectprovides the basic timer support in Qt; see- QChronoTimerfor high-level support for timers.- Notice that the - Q_OBJECTmacro is mandatory for any object that implements signals, slots or properties. You also need to run the Meta Object Compiler on the source file. We strongly recommend the use of this macro in all subclasses of- QObjectregardless 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- qobject_cast<QWidget *>(obj) or obj->- inherits(“QWidget”).- Some - QObjectfunctions, e.g.- children(), return a- QObjectList.- QObjectListis a typedef for- QList<- QObject*>.- Thread Affinity¶- A - QObjectinstance is said to have a thread affinity, or that it lives in a certain thread. When a- QObjectreceives a- queued signalor a posted event , the slot or event handler will run in the thread that the object lives in.- Note - If a - QObjecthas no thread affinity (that is, if- thread()returns zero), or if it lives in a thread that has no running event loop, then it cannot receive queued signals or posted events.- By default, a - QObjectlives in the thread in which it is created. An object’s thread affinity can be queried using- thread()and changed using- moveToThread().- All QObjects must live in the same thread as their parent. Consequently: - setParent()will fail if the two QObjects involved live in different threads.
- When a - QObjectis moved to another thread, all its children will be automatically moved too.
- moveToThread()will fail if the- QObjecthas a parent.
- If QObjects are created within - run(), they cannot become children of the- QThreadobject because the- QThreaddoes not live in the thread that calls- run().
 - Note - A - QObject‘s member variables do not automatically become its children. The parent-child relationship must be set by either passing a pointer to the child’s- constructor, or by calling- setParent(). Without this step, the object’s member variables will remain in the old thread when- moveToThread()is called.- No Copy Constructor or Assignment Operator¶- QObjecthas neither a copy constructor nor an assignment operator. This is by design. Actually, they are declared, but in a- privatesection with the macro- Q_DISABLE_COPY(). In fact, all Qt classes derived from- QObject(direct or indirect) use this macro to declare their copy constructor and assignment operator to be private. The reasoning is found in the discussion on Identity vs Value on the Qt Object Model page.- The main consequence is that you should use pointers to - QObject(or to your- QObjectsubclass) where you might otherwise be tempted to use your- QObjectsubclass as a value. For example, without a copy constructor, you can’t use a subclass of- QObjectas the value to be stored in one of the container classes. You must store pointers.- Auto-Connection¶- Qt’s meta-object system provides a mechanism to automatically connect signals and slots between - QObjectsubclasses and their children. As long as objects are defined with suitable object names, and slots follow a simple naming convention, this connection can be performed at run-time by the- connectSlotsByName()function.- uic generates code that invokes this function to enable auto-connection to be performed between widgets on forms created with Qt Widgets Designer. More information about using auto-connection with Qt Widgets Designer is given in the Using a Designer UI File in Your Application section of the Qt Widgets Designer manual. - Dynamic Properties¶- Dynamic properties can be added to and removed from - QObjectinstances at run-time. Dynamic properties do not need to be declared at compile-time, yet they provide the same advantages as static properties and are manipulated using the same API - using- property()to read them and- setProperty()to write them.- Dynamic properties are supported by Qt Widgets Designer, and both standard Qt widgets and user-created forms can be given dynamic properties. - Internationalization (I18n)¶- All - QObjectsubclasses support Qt’s translation features, making it possible to translate an application’s user interface into different languages.- To make user-visible text translatable, it must be wrapped in calls to the - tr()function. This is explained in detail in the Writing Source Code for Translation document.- See also - QMetaObject- QPointer- QObjectCleanupHandler- Q_DISABLE_COPY()Object Trees & Ownership- Note - Properties can be used directly when - from __feature__ import true_propertyis used or via accessor functions otherwise.- property objectNameᅟ: str¶
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - This property holds the name of this object. - You can find an object by name (and type) using - findChild(). You can find a set of objects with- findChildren().- qDebug("MyClass.setPrecision(): (%s) invalid precision %f", qPrintable(objectName()), newPrecision) - By default, this property contains an empty string. - See also - Access functions:
 - Constructs an object with parent object - parent.- The parent of an object may be viewed as the object’s owner. For instance, a dialog box is the parent of the OK and Cancel buttons it contains. - The destructor of a parent object destroys all child objects. - Setting - parentto- Noneconstructs an object with no parent. If the object is a widget, it will become a top-level window.- See also - blockSignals(b)¶
- Parameters:
- b – bool 
- Return type:
- bool 
 
 - If - blockis true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). If- blockis 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 - childEvent(event)¶
- Parameters:
- event – - QChildEvent
 
 - This event handler can be reimplemented in a subclass to receive child events. The event is passed in the - eventparameter.- ChildAddedand- ChildRemovedevents 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- ChildAddedcase, the child is not yet fully constructed, and in the- ChildRemovedcase it might have been destructed already).- ChildPolishedevents 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 - ChildAddedevent, zero or more- ChildPolishedevents, and one- ChildRemovedevent.- The - ChildPolishedevent 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 - Returns a list of child objects. The - QObjectListclass is defined in the- <QObject>header file as the following:- The first child added is the - firstobject in the list and the last child added is the- lastobject in the list, i.e. new children are appended at the end.- Note that the list order changes when QWidget children are raised or 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 - connect(signal, functor[, type=Qt.AutoConnection])¶
- Parameters:
- signal – str 
- functor – - PyCallable
- type – - ConnectionType
 
- Return type:
 
 - static connect(sender, signal, functor[, type=Qt.AutoConnection])
- Parameters:
- sender – - QObject
- signal – str 
- functor – - PyCallable
- type – - ConnectionType
 
- Return type:
 
 - connect(sender, signal, member[, type=Qt.AutoConnection])
- Parameters:
- sender – - QObject
- signal – str 
- member – str 
- type – - ConnectionType
 
- Return type:
 
 - This function overloads - connect().- Connects - signalfrom the- senderobject to this object’s- method.- Equivalent to connect( - sender,- signal,- this,- method,- type).- Every connection you make emits a signal, so duplicate connections emit two signals. You can break a connection using - disconnect().- See also - connect(signal, receiver, method[, type=Qt.AutoConnection])
- Parameters:
- signal – str 
- receiver – - QObject
- method – str 
- type – - ConnectionType
 
- Return type:
 
 - static connect(sender, signal, receiver, method[, type=Qt.AutoConnection])
- Parameters:
- sender – - QObject
- signal – - QMetaMethod
- receiver – - QObject
- method – - QMetaMethod
- type – - ConnectionType
 
- Return type:
 
 - Creates a connection of the given - typefrom the- signalin the- senderobject to the- methodin the- receiverobject. 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 - Connectionis 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- QMetaMethodto specify signal and method.- See also - ConnectionType type)- static connect(sender, signal, context, functor[, type=Qt.AutoConnection])
- Parameters:
- sender – - QObject
- signal – str 
- context – - QObject
- functor – - PyCallable
- type – - ConnectionType
 
- Return type:
 
 - static connect(sender, signal, receiver, member[, type=Qt.AutoConnection])
- Parameters:
- sender – - QObject
- signal – str 
- receiver – - QObject
- member – str 
- type – - ConnectionType
 
- Return type:
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Creates a connection of the given - typefrom the- signalin the- senderobject to the- methodin the- receiverobject. 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- signaland the- method, for example:- label = QLabel() scrollBar = QScrollBar() QObject.connect(scrollBar, SIGNAL(valueChanged(int)), label, SLOT(setNum(int))) - 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: - # WRONG QObject.connect(scrollBar, SIGNAL(valueChanged(int value)), label, SLOT(setNum(int value))) - A signal can also be connected to another signal: - class MyWidget(QWidget): Q_OBJECT # public MyWidget() # signals def buttonClicked(): # private myButton = QPushButton() def __init__(self): myButton = QPushButton(self) connect(myButton, SIGNAL(clicked()), self, SIGNAL(buttonClicked())) - In this example, the - MyWidgetconstructor 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 - Connectionthat 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- QObjectis unable to verify the existence of either- signalor- 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- 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- Connection.- Note - Qt::UniqueConnections do not work for lambdas, non-member functions and functors; they only apply to connecting to member functions. - The optional - typeparameter 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- QObject.connect: Cannot queue arguments of type 'MyType' (Make sure 'MyType' is registered using qRegisterMetaType().) - 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- connectNotify(signal)¶
- Parameters:
- signal – - QMetaMethod
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - This virtual function is called when something has been connected to - signalin this object.- If you want to compare - signalwith a specific signal, you can use- fromSignal()as follows:- if signal == QMetaMethod.fromSignal(MyObject.valueChanged): # signal is valueChanged - 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. - Warning - 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. This function may also be called with a - QObjectinternal mutex locked. It is therefore not allowed to re-enter any- QObjectfunctions, including- isSignalConnected(), from your reimplementation. If you lock a mutex in your reimplementation, make sure that you don’t call- QObjectfunctions with that mutex held in other places or it will result in a deadlock.- See also - 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 - Useritem of the- Typeenum, and is typically a- QEventsubclass. The event is passed in the- eventparameter.- deleteLater()¶
 - 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 - 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. 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. - In situations where Qt is not driving the event dispatcher via e.g. - exec()or- exec(), deferred deletes will not be processed automatically. To ensure deferred deletion in this scenario, the following workaround can be used:- const auto *eventDispatcher = QThread::currentThread()->eventDispatcher(); QObject::connect(eventDispatcher, &QAbstractEventDispatcher::aboutToBlock, QThread::currentThread(), []{ if (QThread::currentThread()->loopLevel() == 0) QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); } ); - See also - destroyed()- QPointer- This signal is emitted immediately before the object - objis destroyed, after any instances of- QPointerhave been notified, and cannot be blocked.- All the objects’s children are destroyed immediately after this signal is emitted. - See also - deleteLater()- QPointer- static disconnect(connection)¶
- Parameters:
- connection – - Connection
- Return type:
- bool 
 
 - Disconnect a connection. - If the - connectionis invalid or has already been disconnected, do nothing and return false.- See also - disconnect(receiver[, member=None])
- Parameters:
- receiver – - QObject
- member – str 
 
- Return type:
- bool 
 
 - This function overloads - disconnect().- Disconnects all signals in this object from - receiver's- method.- Note - Use the the same syntax, pointer-to-member-function or string-based using the - SIGNALand- SLOTmacros, in- connect()and corresponding- disconnect()calls.- To avoid mismatches, store the connection handle returned by - connect(), and use it in the call to- disconnect().- Note - If a - queued connectionis disconnected, already scheduled events may still be delivered, causing the receiver to be called after the connection is disconnected.- A signal-slot connection is removed when either of the objects involved are destroyed. - disconnect(signal, functor)
- Parameters:
- signal – str 
- functor – - PyCallable
 
- Return type:
- bool 
 
 - static disconnect(sender, signal, functor)
- Parameters:
- sender – - QObject
- signal – str 
- functor – - PyCallable
 
- Return type:
- bool 
 
 - disconnect(signal, receiver, member)
- Parameters:
- signal – str 
- receiver – - QObject
- member – str 
 
- Return type:
- bool 
 
 - This function overloads - disconnect().- Disconnects - signalfrom- methodof- receiver.- Note - Use the the same syntax, pointer-to-member-function or string-based using the - SIGNALand- SLOTmacros, in- connect()and corresponding- disconnect()calls.- To avoid mismatches, store the connection handle returned by - connect(), and use it in the call to- disconnect().- Note - If a - queued connectionis disconnected, already scheduled events may still be delivered, causing the receiver to be called after the connection is disconnected.- A signal-slot connection is removed when either of the objects involved are destroyed. - Note - Disconnecting all signal-slot connections will also disconnect the - destroyed()signal if it is connected. Doing so can adversely affect classes that rely on this signal for cleaning up resources. It is recommended to disconnect only the specific signals that were connected by application code.- static disconnect(sender, signal, receiver, member)
- Parameters:
- sender – - QObject
- signal – - QMetaMethod
- receiver – - QObject
- member – - QMetaMethod
 
- Return type:
- bool 
 
 - Disconnects - signalin object- senderfrom- methodin object- receiver. Returns- trueif 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- QMetaMethodto represent the signal and the method to be disconnected.- Additionally this function returns false and no signals and slots disconnected if: - signalis not a member of sender class or one of its parent classes.
- methodis not a member of receiver class or one of its parent classes.
- signalinstance represents not a signal.
 - Note - Use the the same syntax, pointer-to-member-function or string-based using the - SIGNALand- SLOTmacros, in- connect()and corresponding- disconnect()calls.- To avoid mismatches, store the connection handle returned by - connect(), and use it in the call to- disconnect().- Note - If a - queued connectionis disconnected, already scheduled events may still be delivered, causing the receiver to be called after the connection is disconnected.- QMetaMethod() may be used as wildcard in the meaning “any signal” or “any slot in receiving object”. In the same way - Nonecan be used for- receiverin the meaning “any receiving object”. In this case method should also be QMetaMethod().- senderparameter should be never- None.- Note - Disconnecting all signal-slot connections will also disconnect the - destroyed()signal if it is connected. Doing so can adversely affect classes that rely on this signal for cleaning up resources. It is recommended to disconnect only the specific signals that were connected by application code.- See also - disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)- static disconnect(sender, signal, receiver, member)
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Disconnects - signalin object- senderfrom- methodin object- receiver. Returns- trueif 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.- Disconnect everything connected to an object’s signals: - disconnect(myObject, None, None, None) - equivalent to the non-static overloaded function - myObject.disconnect() 
- Disconnect everything connected to a specific signal: - disconnect(myObject, SIGNAL(mySignal()), None, None) - equivalent to the non-static overloaded function - myObject.disconnect(SIGNAL(mySignal())) 
- Disconnect a specific receiver: - disconnect(myObject, None, myReceiver, None) - equivalent to the non-static overloaded function - myObject.disconnect(myReceiver) 
 - Note - Use the the same syntax, pointer-to-member-function or string-based using the - SIGNALand- SLOTmacros, in- connect()and corresponding- disconnect()calls.- To avoid mismatches, store the connection handle returned by - connect(), and use it in the call to- disconnect().- Note - If a - queued connectionis disconnected, already scheduled events may still be delivered, causing the receiver to be called after the connection is disconnected.- Nonemay be used as a wildcard, meaning “any signal”, “any receiving object”, or “any slot in the receiving object”, respectively.- The - sendermay never be- None. (You cannot disconnect signals from more than one object in a single call.)- If - signalis- None, it disconnects- receiverand- methodfrom any signal. If not, only the specified signal is disconnected.- If - receiveris- None, it disconnects anything connected to- signal. If not, slots in objects other than- receiverare not disconnected.- If - methodis- None, it disconnects anything that is connected to- receiver. If not, only slots named- methodwill be disconnected, and all other slots are left alone. The- methodmust be- Noneif- receiveris left out, so you cannot disconnect a specifically-named slot on all objects.- Note - Disconnecting all signal-slot connections will also disconnect the - destroyed()signal if it is connected. Doing so can adversely affect classes that rely on this signal for cleaning up resources. It is recommended to disconnect only the specific signals that were connected by application code.- See also - disconnectNotify(signal)¶
- Parameters:
- signal – - QMetaMethod
 
 - This virtual function is called when something has been disconnected from - signalin this object.- See - connectNotify()for an example of how to compare- signalwith a specific signal.- If all signals were disconnected from this object (e.g., the signal argument to - disconnect()was- None), disconnectNotify() is only called once, and the- signalwill be an invalid- 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. - Warning - 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 - QObjectinternal mutex locked. It is therefore not allowed to re-enter any- QObjectfunctions, including- isSignalConnected(), from your reimplementation. If you lock a mutex in your reimplementation, make sure that you don’t call- QObjectfunctions with that mutex held in other places or it will result in a deadlock.- See also - dumpObjectInfo()¶
 - Dumps information about signal connections, etc. for this object to the debug output. - dumpObjectTree()¶
 - Dumps a tree of children to the debug output. - dynamicPropertyNames()¶
- Return type:
- .list of QByteArray 
 
 - Returns the names of all properties that were dynamically added to the object using - setProperty().- emit(signal, arg__2)¶
- Parameters:
- signal – str 
- arg__2 
 
- Return type:
- bool 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - This virtual function receives events to an object and should return true if the event - ewas 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: - class MyClass(QWidget): Q_OBJECT # public MyClass(QWidget parent = None) ~MyClass() bool event(QEvent* ev) override if ev.type() == QEvent.PolishRequest: # overwrite handling of PolishRequest if any doThings() return True else:if (ev.type() == QEvent.Show) { # complement handling of Show if any doThings2() QWidget.event(ev) return True # Make sure the rest of events are handled return QWidget.event(ev) - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Filters events if this object has been installed as an event filter for the - watchedobject.- In your reimplementation of this function, if you want to filter the - eventout, i.e. stop it being handled further, return true; otherwise return false.- Example: - class MainWindow(QMainWindow): # public MainWindow() # protected bool eventFilter(QObject obj, QEvent ev) override # private textEdit = QTextEdit() def __init__(self): textEdit = QTextEdit() setCentralWidget(textEdit) textEdit.installEventFilter(self) def eventFilter(self, QObject obj, QEvent event): if obj == textEdit: if event.type() == QEvent.KeyPress: keyEvent = QKeyEvent(event) print("Ate key press", keyEvent.key()) return True else: return False else: # pass the event on to the parent class return QMainWindow.eventFilter(obj, event) - 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 - ShortcutOverridemust be explicitly accepted (by calling- 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 - findChild(type[, name={}[, options=Qt.FindChildrenRecursively]])¶
- Parameters:
- type – - PyTypeObject
- name – str 
- options – Combination of - FindChildOption
 
- Return type:
- object 
 
 - To find the child of a certain - QObject, the first argument of this function should be the child’s type, and the second the name of the child:- ... parent = QWidget() ... # The first argument must be the child type child1 = parent.findChild(QPushButton, "child_button") child2 = parent.findChild(QWidget, "child_widget") - findChildren(type, pattern[, options=Qt.FindChildrenRecursively])¶
- Parameters:
- type – - PyTypeObject
- pattern – - QRegularExpression
- options – Combination of - FindChildOption
 
- Return type:
- PySequence
 
 - findChildren(type[, name={}[, options=Qt.FindChildrenRecursively]])
- Parameters:
- type – - PyTypeObject
- name – str 
- options – Combination of - FindChildOption
 
- Return type:
- PySequence
 
 - Like the method findChild, the first parameter should be the child’s type. - inherits(classname)¶
- Parameters:
- classname – str 
- Return type:
- bool 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Returns - trueif this object is an instance of a class that inherits- classNameor a- QObjectsubclass that inherits- className; otherwise returns- false.- A class is considered to inherit itself. - Example: - timer = QTimer() # QTimer inherits QObject() timer.inherits("QTimer") # returns true timer.inherits("QObject") # returns true timer.inherits("QAbstractButton") # returns false # QVBoxLayout inherits QObject and QLayoutItem layout = QVBoxLayout() layout.inherits("QObject") # returns true layout.inherits("QLayoutItem") # returns true (even though QLayoutItem is not a QObject) - 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()- Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Installs an event filter - filterObjon this object. For example:- monitoredObj.installEventFilter(filterObj) - 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 - filterObjreceives 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. - If - filterObjhas already been installed for this object, this function moves it so it acts as if it was installed last.- Here’s a - KeyPressEaterclass that eats the key presses of its monitored objects:- class KeyPressEater(QObject): Q_OBJECT ... # protected bool eventFilter(QObject obj, QEvent event) override def eventFilter(self, QObject obj, QEvent event): if event.type() == QEvent.KeyPress: keyEvent = QKeyEvent(event) qDebug("Ate key press %d", keyEvent.key()) return True else: # standard event processing return QObject.eventFilter(obj, event) - And here’s how to install it on two widgets: - keyPressEater = KeyPressEater(self) pushButton = QPushButton(self) listView = QListView(self) pushButton.installEventFilter(keyPressEater) listView.installEventFilter(keyPressEater) - 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 - filterObjis in a different thread, this function does nothing. If either- filterObjor 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 - isQuickItemType()¶
- Return type:
- bool 
 
 - Returns - trueif the object is a QQuickItem; otherwise returns- false.- Calling this function is equivalent to calling - inherits("QQuickItem"), except that it is much faster.- isSignalConnected(signal)¶
- Parameters:
- signal – - QMetaMethod
- Return type:
- bool 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Returns - trueif the- signalis connected to at least one receiver, otherwise returns- false.- signalmust be a signal member of this object, otherwise the behaviour is undefined.- valueChangedSignal = QMetaMethod.fromSignal(MyObject.valueChanged) if isSignalConnected(valueChangedSignal): data = QByteArray() data = get_the_value() # expensive operation valueChanged.emit(data) - As the code snippet above illustrates, you can use this function to avoid expensive initialization or emitting a signal that nobody listens to. However, in a multithreaded application, connections might change after this function returns and before the signal gets emitted. - Warning - This function violates the object-oriented principle of modularity. In particular, this function must not be called from an override of - connectNotify()or- disconnectNotify(), as those might get called from any thread.- isWidgetType()¶
- Return type:
- bool 
 
 - Returns - trueif the object is a widget; otherwise returns- false.- Calling this function is equivalent to calling - inherits("QWidget"), except that it is much faster.- isWindowType()¶
- Return type:
- bool 
 
 - Returns - trueif the object is a window; otherwise returns- false.- Calling this function is equivalent to calling - inherits("QWindow"), except that it is much faster.- This is an overloaded function. - killTimer(id)
- Parameters:
- id – int 
 
 - Kills the timer with timer identifier, - id.- The timer identifier is returned by - startTimer()when a timer event is started.- See also - metaObject()¶
- Return type:
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Returns a pointer to the meta-object of this object. - A meta-object contains information about a class that inherits - QObject, e.g. class name, superclass name, properties, signals and slots. Every- QObjectsubclass that contains the- Q_OBJECTmacro will have a meta-object.- The meta-object information is required by the signal/slot connection mechanism and the property system. The - inherits()function also makes use of the meta-object.- If you have no pointer to an actual object instance but still want to access the meta-object of a class, you can use staticMetaObject . - Example: - obj = QPushButton() obj.metaObject().className() # returns "QPushButton" QPushButton.staticMetaObject.className() # returns "QPushButton" - See also - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Changes the thread affinity for this object and its children and returns - trueon success. 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: - myObject.moveToThread(QApplication.instance().thread()) - If - targetThreadis- None, 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 - ThreadChangeevent 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- None: when it is- None, 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 - objectName()¶
- Return type:
- str 
 - See also 
 - Getter of property - objectNameᅟ.- objectNameChanged(objectName)¶
- Parameters:
- objectName – str 
 
 - This signal is emitted after the object’s name has been changed. The new object name is passed as - objectName.- See also - Notification signal of property - objectNameᅟ.- Returns a pointer to the parent object. - See also - property(name)¶
- Parameters:
- name – str 
- Return type:
- object 
 
 - Returns the value of the object’s - nameproperty.- 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()- isValid()- metaObject()- dynamicPropertyNames()- receivers(signal)¶
- Parameters:
- signal – str 
- Return type:
- int 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - 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:- if receivers(SIGNAL(valueChanged(QByteArray))) > 0: data = QByteArray() get_the_value(data) # expensive operation valueChanged.emit(data) - 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 - Removes an event filter object - objfrom 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 - Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns - None. 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. - Warning - As mentioned above, the return value of this function is not valid when the slot is called via a - DirectConnectionfrom a thread different from this object’s thread. Do not use this function in this type of scenario.- See also - senderSignalIndex()¶
- Return type:
- int 
 
 - 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. - Warning - The return value of this function is not valid when the slot is called via a - DirectConnectionfrom a thread different from this object’s thread. Do not use this function in this type of scenario.- See also - setObjectName(name)¶
- Parameters:
- name – str 
 
 - This is an overloaded function. - Makes the object a child of - parent.- See also - setProperty(name, value)¶
- Parameters:
- name – str 
- value – object 
 
- Return type:
- bool 
 
 - Sets the value of the object’s - nameproperty to- value.- If the property is defined in the class using - Q_PROPERTYthen 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- QDynamicPropertyChangeEventto be sent to the object.- Note - Dynamic properties starting with “_q_” are reserved for internal purposes. - signalsBlocked()¶
- Return type:
- bool 
 
 - Returns - trueif signals are blocked; otherwise returns- false.- Signals are not blocked by default. - See also - startTimer(interval[, timerType=Qt.CoarseTimer])¶
- Parameters:
- interval – int 
- timerType – - TimerType
 
- Return type:
- int 
 
 - This is an overloaded function that will start a timer of type - timerTypeand a timeout of- intervalmilliseconds. This is equivalent to calling:- startTimer(std::chrono::milliseconds{interval}, timerType); - See also - timerEvent()- killTimer()- QChronoTimer- QBasicTimer- Returns the thread in which the object lives. - See also - timerEvent(event)¶
- Parameters:
- event – - QTimerEvent
 
 - This event handler can be reimplemented in a subclass to receive timer events for the object. - QChronoTimerprovides higher-level interfaces to the timer functionality, and also more general information about timers. The timer event is passed in the- eventparameter.- See also - tr(sourceText[, disambiguation=None[, n=-1]])¶
- Parameters:
- sourceText – str 
- disambiguation – str 
- n – int 
 
- Return type:
- str