继承者: Qt3DAnimation.QAbstractAnimation , Qt3DAnimation.QAbstractAnimationClip , Qt3DAnimation.QAbstractChannelMapping , Qt3DAnimation.QAbstractClipAnimator , Qt3DAnimation.QAbstractClipBlendNode , Qt3DAnimation.QAdditiveClipBlend , Qt3DAnimation.QAnimationAspect , Qt3DAnimation.QAnimationClip , Qt3DAnimation.QAnimationClipLoader , Qt3DAnimation.QAnimationController , Qt3DAnimation.QAnimationGroup , Qt3DAnimation.QBlendedClipAnimator , Qt3DAnimation.QClipAnimator , Qt3DAnimation.QClock , Qt3DAnimation.QKeyframeAnimation , Qt3DAnimation.QLerpClipBlend , Qt3DAnimation.QMorphTarget , Qt3DAnimation.QMorphingAnimation , Qt3DAnimation.QSkeletonMapping , Qt3DAnimation.QVertexBlendAnimation , Qt3DCore.QAbstractAspect , Qt3DCore.QAbstractSkeleton , Qt3DCore.QArmature , Qt3DCore.QAspectEngine , Qt3DCore.QComponent , Qt3DCore.QEntity , Qt3DCore.QJoint , Qt3DCore.QNode , Qt3DCore.QSkeleton , Qt3DCore.QSkeletonLoader , Qt3DCore.QTransform , Qt3DExtras.QAbstractCameraController , Qt3DExtras.QAbstractSpriteSheet , Qt3DExtras.QConeGeometry , Qt3DExtras.QConeMesh , Qt3DExtras.QCuboidGeometry , Qt3DExtras.QCuboidMesh , Qt3DExtras.QCylinderGeometry , Qt3DExtras.QCylinderMesh , Qt3DExtras.QDiffuseMapMaterial , Qt3DExtras.QDiffuseSpecularMapMaterial , Qt3DExtras.QDiffuseSpecularMaterial , Qt3DExtras.QExtrudedTextGeometry , Qt3DExtras.QExtrudedTextMesh , Qt3DExtras.QFirstPersonCameraController , Qt3DExtras.QForwardRenderer , Qt3DExtras.QGoochMaterial , Qt3DExtras.QMetalRoughMaterial , Qt3DExtras.QMorphPhongMaterial , Qt3DExtras.QNormalDiffuseMapMaterial , Qt3DExtras.QNormalDiffuseSpecularMapMaterial , Qt3DExtras.QOrbitCameraController , Qt3DExtras.QPerVertexColorMaterial , Qt3DExtras.QPhongAlphaMaterial , Qt3DExtras.QPhongMaterial , Qt3DExtras.QPlaneGeometry , Qt3DExtras.QPlaneMesh , Qt3DExtras.QSkyboxEntity , Qt3DExtras.QSphereGeometry , Qt3DExtras.QSphereMesh , Qt3DExtras.QSpriteGrid , Qt3DExtras.QSpriteSheet , Qt3DExtras.QSpriteSheetItem , Qt3DExtras.QText2DEntity , Qt3DExtras.QTextureMaterial , Qt3DExtras.QTorusGeometry , Qt3DExtras.QTorusMesh , Qt3DExtras.Qt3DWindow , Qt3DInput.QAbstractActionInput , Qt3DInput.QAbstractAxisInput , Qt3DInput.QAbstractPhysicalDevice , Qt3DInput.QAction , Qt3DInput.QActionInput , Qt3DInput.QAnalogAxisInput , Qt3DInput.QAxis , Qt3DInput.QAxisAccumulator , Qt3DInput.QAxisSetting , Qt3DInput.QButtonAxisInput , Qt3DInput.QInputAspect , Qt3DInput.QInputChord , Qt3DInput.QInputSequence , Qt3DInput.QInputSettings , Qt3DInput.QKeyEvent , Qt3DInput.QKeyboardDevice , Qt3DInput.QKeyboardHandler , Qt3DInput.QLogicalDevice , Qt3DInput.QMouseDevice , Qt3DInput.QMouseEvent , Qt3DInput.QMouseHandler , Qt3DInput.QWheelEvent , Qt3DLogic.QFrameAction , Qt3DLogic.QLogicAspect , Qt3DRender.QAbstractLight , Qt3DRender.QAbstractRayCaster , Qt3DRender.QAbstractTexture , Qt3DRender.QAbstractTextureImage , Qt3DRender.QAlphaCoverage , Qt3DRender.QAlphaTest , Qt3DRender.QAttribute , Qt3DRender.QBlendEquation , Qt3DRender.QBlendEquationArguments , Qt3DRender.QBlitFramebuffer , Qt3DRender.QBuffer , Qt3DRender.QBufferCapture , Qt3DRender.QCamera , Qt3DRender.QCameraLens , Qt3DRender.QCameraSelector , Qt3DRender.QClearBuffers , Qt3DRender.QClipPlane , Qt3DRender.QColorMask , Qt3DRender.QComputeCommand , Qt3DRender.QCullFace , Qt3DRender.QDepthTest , Qt3DRender.QDirectionalLight , Qt3DRender.QDispatchCompute , Qt3DRender.QDithering , Qt3DRender.QEffect , Qt3DRender.QEnvironmentLight , Qt3DRender.QFilterKey , Qt3DRender.QFrameGraphNode , Qt3DRender.QFrontFace , Qt3DRender.QFrustumCulling , Qt3DRender.QGeometry , Qt3DRender.QGeometryRenderer , Qt3DRender.QGraphicsApiFilter , Qt3DRender.QLayer , Qt3DRender.QLayerFilter , Qt3DRender.QLevelOfDetail , Qt3DRender.QLevelOfDetailSwitch , Qt3DRender.QLineWidth , Qt3DRender.QMaterial , Qt3DRender.QMemoryBarrier , Qt3DRender.QMesh , Qt3DRender.QMultiSampleAntiAliasing , Qt3DRender.QNoDepthMask , Qt3DRender.QNoDraw , Qt3DRender.QNoPicking , Qt3DRender.QObjectPicker , Qt3DRender.QPaintedTextureImage , Qt3DRender.QParameter , Qt3DRender.QPickEvent , Qt3DRender.QPickLineEvent , Qt3DRender.QPickPointEvent , Qt3DRender.QPickTriangleEvent , Qt3DRender.QPickingSettings , Qt3DRender.QPointLight , Qt3DRender.QPointSize , Qt3DRender.QPolygonOffset , Qt3DRender.QProximityFilter , Qt3DRender.QRayCaster , Qt3DRender.QRenderAspect , Qt3DRender.QRenderCapabilities , Qt3DRender.QRenderCapture , Qt3DRender.QRenderCaptureReply , Qt3DRender.QRenderPass , Qt3DRender.QRenderPassFilter , Qt3DRender.QRenderSettings , Qt3DRender.QRenderState , Qt3DRender.QRenderStateSet , Qt3DRender.QRenderSurfaceSelector , Qt3DRender.QRenderTarget , Qt3DRender.QRenderTargetOutput , Qt3DRender.QRenderTargetSelector , Qt3DRender.QSceneLoader , Qt3DRender.QScissorTest , Qt3DRender.QScreenRayCaster , Qt3DRender.QSeamlessCubemap , Qt3DRender.QSetFence , Qt3DRender.QShaderData , Qt3DRender.QShaderImage , Qt3DRender.QShaderProgram , Qt3DRender.QShaderProgramBuilder , Qt3DRender.QSharedGLTexture , Qt3DRender.QSortPolicy , Qt3DRender.QSpotLight , Qt3DRender.QStencilMask , Qt3DRender.QStencilOperation , Qt3DRender.QStencilOperationArguments , Qt3DRender.QStencilTest , Qt3DRender.QStencilTestArguments , Qt3DRender.QTechnique , Qt3DRender.QTechniqueFilter , Qt3DRender.QTexture1D , Qt3DRender.QTexture1DArray , Qt3DRender.QTexture2D , Qt3DRender.QTexture2DArray , Qt3DRender.QTexture2DMultisample , Qt3DRender.QTexture2DMultisampleArray , Qt3DRender.QTexture3D , Qt3DRender.QTextureBuffer , Qt3DRender.QTextureCubeMap , Qt3DRender.QTextureCubeMapArray , Qt3DRender.QTextureImage , Qt3DRender.QTextureLoader , Qt3DRender.QTextureRectangle , Qt3DRender.QTextureWrapMode , Qt3DRender.QViewport , Qt3DRender.QWaitFence , QtCharts.QAbstractAxis , QtCharts.QAbstractBarSeries , QtCharts.QAbstractSeries , QtCharts.QAreaLegendMarker , QtCharts.QAreaSeries , QtCharts.QBarCategoryAxis , QtCharts.QBarLegendMarker , QtCharts.QBarModelMapper , QtCharts.QBarSeries , QtCharts.QBarSet , QtCharts.QBoxPlotLegendMarker , QtCharts.QBoxPlotModelMapper , QtCharts.QBoxPlotSeries , QtCharts.QBoxSet , QtCharts.QCandlestickLegendMarker , QtCharts.QCandlestickModelMapper , QtCharts.QCandlestickSeries , QtCharts.QCandlestickSet , QtCharts.QCategoryAxis , QtCharts.QChart , QtCharts.QChartView , QtCharts.QDateTimeAxis , QtCharts.QHBarModelMapper , QtCharts.QHBoxPlotModelMapper , QtCharts.QHCandlestickModelMapper , QtCharts.QHPieModelMapper , QtCharts.QHXYModelMapper , QtCharts.QHorizontalBarSeries , QtCharts.QHorizontalPercentBarSeries , QtCharts.QHorizontalStackedBarSeries , QtCharts.QLegend , QtCharts.QLegendMarker , QtCharts.QLineSeries , QtCharts.QLogValueAxis , QtCharts.QPercentBarSeries , QtCharts.QPieLegendMarker , QtCharts.QPieModelMapper , QtCharts.QPieSeries , QtCharts.QPieSlice , QtCharts.QPolarChart , QtCharts.QScatterSeries , QtCharts.QSplineSeries , QtCharts.QStackedBarSeries , QtCharts.QVBarModelMapper , QtCharts.QVBoxPlotModelMapper , QtCharts.QVCandlestickModelMapper , QtCharts.QVPieModelMapper , QtCharts.QVXYModelMapper , QtCharts.QValueAxis , QtCharts.QXYLegendMarker , QtCharts.QXYModelMapper , QtCharts.QXYSeries , QAbstractAnimation , QAbstractEventDispatcher , QAbstractItemModel , QAbstractListModel , QAbstractProxyModel , QAbstractState , QAbstractTableModel , QAbstractTransition , QAnimationGroup , QBuffer , QConcatenateTablesProxyModel , QCoreApplication , QEventLoop , QEventTransition , QFile , QFileDevice , QFileSelector , QFileSystemWatcher , QFinalState , QHistoryState , QIODevice , QIdentityProxyModel , QItemSelectionModel , QMimeData , QParallelAnimationGroup , QPauseAnimation , QPluginLoader , QProcess , QPropertyAnimation , QSaveFile , QSequentialAnimationGroup , QSettings , QSignalMapper , QSignalTransition , QSocketNotifier , QSortFilterProxyModel , QState , QStateMachine , QStringListModel , QTemporaryFile , QThread , QThreadPool , QTimeLine , QTimer , QTranslator , QTransposeProxyModel , QVariantAnimation , QtDataVisualization.Q3DBars , QtDataVisualization.Q3DCamera , QtDataVisualization.Q3DInputHandler , QtDataVisualization.Q3DLight , QtDataVisualization.Q3DObject , QtDataVisualization.Q3DScatter , QtDataVisualization.Q3DScene , QtDataVisualization.Q3DSurface , QtDataVisualization.Q3DTheme , QtDataVisualization.QAbstract3DAxis , QtDataVisualization.QAbstract3DGraph , QtDataVisualization.QAbstract3DInputHandler , QtDataVisualization.QAbstract3DSeries , QtDataVisualization.QAbstractDataProxy , QtDataVisualization.QBar3DSeries , QtDataVisualization.QBarDataProxy , QtDataVisualization.QCategory3DAxis , QtDataVisualization.QCustom3DItem , QtDataVisualization.QCustom3DLabel , QtDataVisualization.QCustom3DVolume , QtDataVisualization.QHeightMapSurfaceDataProxy , QtDataVisualization.QItemModelBarDataProxy , QtDataVisualization.QItemModelScatterDataProxy , QtDataVisualization.QItemModelSurfaceDataProxy , QtDataVisualization.QLogValue3DAxisFormatter , QtDataVisualization.QScatter3DSeries , QtDataVisualization.QScatterDataProxy , QtDataVisualization.QSurface3DSeries , QtDataVisualization.QSurfaceDataProxy , QtDataVisualization.QTouch3DInputHandler , QtDataVisualization.QValue3DAxis , QtDataVisualization.QValue3DAxisFormatter , QAbstractTextDocumentLayout , QClipboard , QDoubleValidator , QDrag , QGuiApplication , QInputMethod , QIntValidator , QMovie , QOffscreenSurface , QOpenGLContext , QOpenGLContextGroup , QOpenGLDebugLogger , QOpenGLShader , QOpenGLShaderProgram , QOpenGLTimeMonitor , QOpenGLTimerQuery , QOpenGLVertexArrayObject , QOpenGLWindow , QPaintDeviceWindow , QPdfWriter , QRasterWindow , QRegExpValidator , QRegularExpressionValidator , QScreen , QSessionManager , QStandardItemModel , QStyleHints , QSyntaxHighlighter , QTextBlockGroup , QTextDocument , QTextFrame , QTextList , QTextObject , QTextTable , QValidator , QWindow , QHelpContentModel , QHelpContentWidget , QHelpEngine , QHelpEngineCore , QHelpFilterEngine , QHelpFilterSettingsWidget , QHelpIndexModel , QHelpIndexWidget , QHelpSearchEngine , QHelpSearchQueryWidget , QHelpSearchResultWidget , QGeoCodeReply , QGeoCodingManager , QGeoCodingManagerEngine , QGeoRouteReply , QGeoRoutingManager , QGeoRoutingManagerEngine , QGeoServiceProvider , QPlaceContentReply , QPlaceDetailsReply , QPlaceIdReply , QPlaceManager , QPlaceManagerEngine , QPlaceMatchReply , QPlaceReply , QPlaceSearchReply , QPlaceSearchSuggestionReply , QAbstractAudioDeviceInfo , QAbstractAudioInput , QAbstractAudioOutput , QAbstractVideoFilter , QAbstractVideoSurface , QAudioDecoder , QAudioDecoderControl , QAudioEncoderSettingsControl , QAudioInput , QAudioInputSelectorControl , QAudioOutput , QAudioOutputSelectorControl , QAudioProbe , QAudioRecorder , QAudioRoleControl , QCamera , QCameraCaptureBufferFormatControl , QCameraCaptureDestinationControl , QCameraControl , QCameraExposure , QCameraExposureControl , QCameraFeedbackControl , QCameraFlashControl , QCameraFocus , QCameraFocusControl , QCameraImageCapture , QCameraImageCaptureControl , QCameraImageProcessing , QCameraImageProcessingControl , QCameraInfoControl , QCameraLocksControl , QCameraViewfinderSettingsControl , QCameraViewfinderSettingsControl2 , QCameraZoomControl , QCustomAudioRoleControl , QImageEncoderControl , QMediaAudioProbeControl , QMediaAvailabilityControl , QMediaContainerControl , QMediaControl , QMediaGaplessPlaybackControl , QMediaNetworkAccessControl , QMediaObject , QMediaPlayer , QMediaPlayerControl , QMediaPlaylist , QMediaRecorder , QMediaRecorderControl , QMediaService , QMediaStreamsControl , QMediaVideoProbeControl , QMetaDataReaderControl , QMetaDataWriterControl , QRadioData , QRadioDataControl , QRadioTuner , QRadioTunerControl , QSound , QSoundEffect , QVideoDeviceSelectorControl , QVideoEncoderSettingsControl , QVideoProbe , QVideoRendererControl , QVideoWindowControl , QCameraViewfinder , QGraphicsVideoItem , QVideoWidget , QVideoWidgetControl , QAbstractNetworkCache , QAbstractSocket , QDnsLookup , QDtls , QHttpMultiPart , QLocalServer , QLocalSocket , QNetworkAccessManager , QNetworkConfigurationManager , QNetworkCookieJar , QNetworkDiskCache , QNetworkReply , QNetworkSession , QSslSocket , QTcpServer , QTcpSocket , QUdpSocket , QGLShader , QGLShaderProgram , QGLWidget , QGeoAreaMonitorSource , QGeoPositionInfoSource , QGeoSatelliteInfoSource , QNmeaPositionInfoSource , QAbstractPrintDialog , QPageSetupDialog , QPrintDialog , QPrintPreviewDialog , QPrintPreviewWidget , QJSEngine , QQmlApplicationEngine , QQmlComponent , QQmlContext , QQmlEngine , QQmlExpression , QQmlExtensionPlugin , QQmlFileSelector , QQmlPropertyMap , QQuickFramebufferObject , QQuickImageResponse , QQuickItem , QQuickItemGrabResult , QQuickPaintedItem , QQuickRenderControl , QQuickTextDocument , QQuickTextureFactory , QQuickTransform , QQuickView , QQuickWindow , QSGAbstractRenderer , QSGDynamicTexture , QSGEngine , QSGTexture , QSGTextureProvider , QQuickWidget , QScxmlCppDataModel , QScxmlDataModel , QScxmlDynamicScxmlServiceFactory , QScxmlEcmaScriptDataModel , QScxmlInvokableService , QScxmlInvokableServiceFactory , QScxmlNullDataModel , QScxmlStateMachine , QScxmlStaticScxmlServiceFactory , QAccelerometer , QAccelerometerReading , QAltimeter , QAltimeterReading , QAmbientLightReading , QAmbientLightSensor , QAmbientTemperatureReading , QAmbientTemperatureSensor , QCompass , QCompassReading , QDistanceReading , QDistanceSensor , QGyroscope , QGyroscopeReading , QHolsterReading , QHolsterSensor , QHumidityReading , QHumiditySensor , QIRProximityReading , QIRProximitySensor , QLidReading , QLidSensor , QLightReading , QLightSensor , QMagnetometer , QMagnetometerReading , QOrientationReading , QOrientationSensor , QPressureReading , QPressureSensor , QProximityReading , QProximitySensor , QRotationReading , QRotationSensor , QSensor , QSensorBackend , QSensorGestureManager , QSensorGestureRecognizer , QSensorReading , QTapReading , QTapSensor , QTiltReading , QTiltSensor , QSqlDriver , QSqlQueryModel , QSqlRelationalTableModel , QSqlTableModel , QGraphicsSvgItem , QSvgRenderer , QSvgWidget , QTextToSpeech , QTextToSpeechEngine , QUiLoader , QWebChannel , QWebChannelAbstractTransport , QWebEngineCookieStore , QWebEngineUrlRequestInterceptor , QWebEngineUrlRequestJob , QWebEngineUrlSchemeHandler , QWebEngineDownloadItem , QWebEnginePage , QWebEngineProfile , QWebEngineView , QMaskGenerator , QWebSocket , QWebSocketServer , QAbstractButton , QAbstractItemDelegate , QAbstractItemView , QAbstractScrollArea , QAbstractSlider , QAbstractSpinBox , QAction , QActionGroup , QApplication , QBoxLayout , QButtonGroup , QCalendarWidget , QCheckBox , QColorDialog , QColumnView , QComboBox , QCommandLinkButton , QCommonStyle , QCompleter , QDataWidgetMapper , QDateEdit , QDateTimeEdit , QDesktopWidget , QDial , QDialog , QDialogButtonBox , QDirModel , QDockWidget , QDoubleSpinBox , QErrorMessage , QFileDialog , QFileSystemModel , QFocusFrame , QFontComboBox , QFontDialog , QFormLayout , QFrame , QGesture , QGraphicsAnchor , QGraphicsBlurEffect , QGraphicsColorizeEffect , QGraphicsDropShadowEffect , QGraphicsEffect , QGraphicsItemAnimation , QGraphicsObject , QGraphicsOpacityEffect , QGraphicsProxyWidget , QGraphicsRotation , QGraphicsScale , QGraphicsScene , QGraphicsTextItem , QGraphicsTransform , QGraphicsView , QGraphicsWidget , QGridLayout , QGroupBox , QHBoxLayout , QHeaderView , QInputDialog , QItemDelegate , QKeyEventTransition , QKeySequenceEdit , QLCDNumber , QLabel , QLayout , QLineEdit , QListView , QListWidget , QMainWindow , QMdiArea , QMdiSubWindow , QMenu , QMenuBar , QMessageBox , QMouseEventTransition , QOpenGLWidget , QPanGesture , QPinchGesture , QPlainTextDocumentLayout , QPlainTextEdit , QProgressBar , QProgressDialog , QProxyStyle , QPushButton , QRadioButton , QRubberBand , QScrollArea , QScrollBar , QScroller , QShortcut , QSizeGrip , QSlider , QSpinBox , QSplashScreen , QSplitter , QSplitterHandle , QStackedLayout , QStackedWidget , QStatusBar , QStyle , QStyledItemDelegate , QSwipeGesture , QSystemTrayIcon , QTabBar , QTabWidget , QTableView , QTableWidget , QTapAndHoldGesture , QTapGesture , QTextBrowser , QTextEdit , QTimeEdit , QToolBar , QToolBox , QToolButton , QTreeView , QTreeWidget , QUndoGroup , QUndoStack , QUndoView , QVBoxLayout , QWidget , QWidgetAction , QWizard , QWizardPage , QAbstractMessageHandler , QAbstractUriResolver
def
blockSignals
(b)
def
children
()
def
connect
(arg__1, arg__2, arg__3[, type=Qt.AutoConnection])
def
connect
(arg__1, arg__2[, type=Qt.AutoConnection])
def
connect
(sender, signal, member[, type=Qt.AutoConnection])
def
disconnect
(arg__1, arg__2)
def
disconnect
(receiver[, member=None])
def
disconnect
(signal, receiver, member)
def
dumpObjectInfo
()
def
dumpObjectTree
()
def
dynamicPropertyNames
()
def
emit
(arg__1, arg__2)
def
findChild
(arg__1[, arg__2=””])
def
findChildren
(arg__1, arg__2)
def
findChildren
(arg__1[, arg__2=””])
def
继承
(classname)
def
installEventFilter
(filterObj)
def
isSignalConnected
(signal)
def
isWidgetType
()
def
isWindowType
()
def
killTimer
(id)
def
moveToThread
(thread)
def
objectName
()
def
parent
()
def
特性
(name)
def
receivers
(signal)
def
removeEventFilter
(obj)
def
sender
()
def
senderSignalIndex
()
def
setObjectName
(name)
def
setParent
(parent)
def
setProperty
(name, value)
def
signalsBlocked
()
def
startTimer
(interval[, timerType=Qt.CoarseTimer])
def
thread
()
def
tr
(arg__1[, arg__2=0[, arg__3=-1]])
def
childEvent
(event)
def
connectNotify
(signal)
def
customEvent
(event)
def
disconnectNotify
(signal)
def
event
(event)
def
eventFilter
(watched, event)
def
metaObject
()
def
timerEvent
(event)
def
deleteLater
()
def
connect
(arg__1, arg__2, arg__3[, type=Qt.AutoConnection])
def
connect
(sender, signal, receiver, member[, type=Qt.AutoConnection])
def
connect
(sender, signal, receiver, method[, type=Qt.AutoConnection])
def
disconnect
(arg__1)
def
disconnect
(arg__1, arg__2, arg__3)
def
disconnect
(sender, signal, receiver, member)
def
disconnect
(sender, signal, receiver, member)
def
registerUserData
()
QObjectis the heart of the Qt 对象模型 。该模型的中心特征是非常强大的无缝对象通信机制,称为 信号和槽 。可以连接信号到槽采用connect()and destroy the connection withdisconnect(). To avoid never ending notification loops you can temporarily block signals withblockSignals(). The protected functionsconnectNotify()anddisconnectNotify()make it possible to track connections.QObjects organize themselves in 对象树 . When you create a
QObjectwith another object as parent, the object will automatically add itself to the parent’schildren()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 usingfindChild()orfindChildren().Every object has an
objectName()and its class name can be found via the correspondingmetaObject()(见className()). You can determine whether the object’s class inherits another class in theQObjectinheritance hierarchy by using theinherits()函数。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. SeeinstallEventFilter()andeventFilter()for details. A convenience handler,childEvent(), can be reimplemented to catch child events.Last but not least,
QObjectprovides the basic timer support in Qt; seeQTimerfor 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 ofQObjectregardless 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 functionisWidgetType()returns whether an object is actually a widget. It is much faster thanqobject_cast<QWidget*>( obj ) or obj ->继承(”QWidget“).Some
QObjectfunctions, e.g.children(), return aQObjectList.QObjectListis a typedef forQList<QObject*>.
A
QObjectinstance is said to have a 线程倾向性 , or that it lives in a certain thread. When aQObject接收queued signal或 posted event , the slot or event handler will run in the thread that the object lives in.注意
若
QObjecthas no thread affinity (that is, ifthread()returns zero), or if it lives in a thread that has no running event loop, then it cannot receive queued signals or posted events.默认情况下,
QObjectlives in the thread in which it is created. An object’s thread affinity can be queried usingthread()and changed usingmoveToThread().所有 QObject 必须活在如其父级的相同线程内。因此:
setParent()will fail if the two QObjects involved live in different threads.当
QObjectis moved to another thread, all its children will be automatically moved too.
moveToThread()will fail if theQObjecthas a parent.If QObjects are created within
run(), they cannot become children of theQThreadobject because theQThreaddoes not live in the thread that callsrun().注意
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构造函数, or by callingsetParent(). Without this step, the object’s member variables will remain in the old thread whenmoveToThread()被调用。
QObjecthas neither a copy constructor nor an assignment operator. This is by design. Actually, they are declared, but in aprivatesection with the macroQ_DISABLE_COPY(). In fact, all Qt classes derived fromQObject(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 对象模型 页面。The main consequence is that you should use pointers to
QObject(or to yourQObjectsubclass) where you might otherwise be tempted to use yourQObjectsubclass as a value. For example, without a copy constructor, you can’t use a subclass ofQObjectas the value to be stored in one of the container classes. You must store pointers.
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 theconnectSlotsByName()函数。uic generates code that invokes this function to enable auto-connection to be performed between widgets on forms created with Qt Designer . More information about using auto-connection with Qt Designer is given in the Using a Designer UI File in Your Application section of the Qt Designer 手册。
From Qt 4.2, 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 - usingproperty()to read them andsetProperty()to write them.From Qt 4.3, dynamic properties are supported by Qt Designer, and both standard Qt widgets and user-created forms can be given dynamic properties.
所有
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.另请参阅
QMetaObjectQPointerQObjectCleanupHandlerQ_DISABLE_COPY()对象树 & 所有权
QObject
(
[
parent=None
]
)
¶
- param parent
构造对象采用父级对象
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.
父级对象的析构函数会销毁所有子级对象。
设置
parent
to
None
constructs an object with no parent. If the object is a widget, it will become a top-level window.
PySide2.QtCore.QObject.
blockSignals
(
b
)
¶
b
–
bool
bool
若
block
为 true,阻塞由此对象发射的信号 (即:发射信号不会援引与其连接的任何东西)。若
block
为 false,不会发生这种阻塞。
返回值是先前值的
signalsBlocked()
.
注意:
destroyed()
signal will be emitted even if the signals for this object have been blocked.
当被阻塞时发出的信号,不会被缓冲。
PySide2.QtCore.QObject.
childEvent
(
event
)
¶
event
–
QChildEvent
可以在子类中重实现此事件处理程序以接收子级事件。事件被传入
event
参数。
ChildAdded
and
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
,或者若
isWidgetType()
返回
true
,
QWidget
. (This is because, in the
ChildAdded
case, the child is not yet fully constructed, and in the
ChildRemoved
case it might have been destructed already).
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
ChildAdded
event, zero or more
ChildPolished
events, and one
ChildRemoved
事件。
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.
另请参阅
PySide2.QtCore.QObject.
children
(
)
¶
返回子级对象的列表。
QObjectList
类被定义于
<QObject>
头文件,如下所示:
第一添加子级是
first
对象在列表中,且最后添加子级是
last
对象在列表中,即:新子级被追加在末尾。
注意:列表次序改变,当
QWidget
子级
raised
or
lowered
。被提升 Widget 变为最后列表对象,被降低 Widget 变为第一列表对象。
PySide2.QtCore.QObject.
connect
(
arg__1
,
arg__2
,
arg__3
[
,
type=Qt.AutoConnection
]
)
¶
arg__1
–
QObject
arg__2 – str
arg__3
–
PyCallable
type
–
ConnectionType
bool
PySide2.QtCore.QObject.
connect
(
sender
,
signal
,
receiver
,
方法
[
,
type=Qt.AutoConnection
]
)
¶
sender
–
QObject
signal
–
QMetaMethod
receiver
–
QObject
方法
–
QMetaMethod
type
–
ConnectionType
Connection
PySide2.QtCore.QObject.
connect
(
sender
,
signal
,
receiver
,
member
[
,
type=Qt.AutoConnection
]
)
¶
Connection
Creates a connection of the given
type
从
signal
在
sender
object to the
方法
在
receiver
object. Returns a handle to the connection that can be used to disconnect it later.
必须使用
SIGNAL()
and
SLOT()
宏当指定
signal
和
方法
,例如:
label = QLabel()
scrollBar = QScrollBar()
QObject.connect(scrollBar, SIGNAL('valueChanged(int)'),
label, SLOT('setNum(int)'));
# or scrollBar.valueChanged.connect(label.setNum)
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):
def __init__(self):
myButton = QPushButton(self)
myButton.clicked.connect(self.buttonClicked)
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
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
方法
, 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
.
注意
Qt::UniqueConnections do not work for lambdas, non-member functions and functors; they only apply to connecting to member functions.
可选
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
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.
另请参阅
disconnect()
sender()
qRegisterMetaType()
Q_DECLARE_METATYPE()
Differences
between
String-Based
and
Functor-Based
Connections
PySide2.QtCore.QObject.
connect
(
sender
,
signal
,
member
[
,
type=Qt.AutoConnection
]
)
¶
sender
–
QObject
signal – str
member – str
type
–
ConnectionType
Connection
此函数重载
connect()
.
Connects
signal
从
sender
object to this object’s
方法
.
相当于 connect(
sender
,
signal
,
this
,
方法
,
type
).
Every connection you make emits a signal, so duplicate connections emit two signals. You can break a connection using
disconnect()
.
另请参阅
PySide2.QtCore.QObject.
connect
(
arg__1
,
arg__2
[
,
type=Qt.AutoConnection
]
)
¶
arg__1 – str
arg__2
–
PyCallable
type
–
ConnectionType
bool
PySide2.QtCore.QObject.
connect
(
arg__1
,
arg__2
,
arg__3
[
,
type=Qt.AutoConnection
]
)
¶
arg__1 – str
arg__2
–
QObject
arg__3 – str
type
–
ConnectionType
bool
PySide2.QtCore.QObject.
connectNotify
(
signal
)
¶
signal
–
QMetaMethod
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
fromSignal()
as follows:
if QLatin1String(signal) == SIGNAL('valueChanged()'):
# signal is valueChanged()
警告
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.
PySide2.QtCore.QObject.
customEvent
(
event
)
¶
event
–
QEvent
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
User
item of the
Type
enum, and is typically a
QEvent
subclass. The event is passed in the
event
参数。
PySide2.QtCore.QObject.
deleteLater
(
)
¶
安排删除此对象。
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. is called on an object before
exec()
), the object will be deleted once the event loop is started. If is called after the main event loop has stopped, the object will not be deleted. Since Qt 4.8, if is called on an object that lives in a thread with no running event loop, the object will be destroyed when the thread finishes.
注意:进入和离开新事件循环 (如,通过打开模态对话框) 会 not perform the deferred deletion; for the object to be deleted, the control must return to the event loop from which 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.
注意
多次调用此函数是安全的;当交付首个延迟删除事件时,对象的任何待决事件均将从事件队列中被移除。
另请参阅
destroyed()
QPointer
PySide2.QtCore.QObject.
disconnect
(
receiver
[
,
member=None
]
)
¶
receiver
–
QObject
member – str
bool
此函数重载
disconnect()
.
Disconnects all signals in this object from
receiver
‘s
方法
.
A signal-slot connection is removed when either of the objects involved are destroyed.
PySide2.QtCore.QObject.
disconnect
(
signal
,
receiver
,
member
)
¶
signal – str
receiver
–
QObject
member – str
bool
此函数重载
disconnect()
.
Disconnects
signal
from
方法
of
receiver
.
A signal-slot connection is removed when either of the objects involved are destroyed.
PySide2.QtCore.QObject.
disconnect
(
arg__1
,
arg__2
)
¶
arg__1 – str
arg__2
–
PyCallable
bool
PySide2.QtCore.QObject.
disconnect
(
sender
,
signal
,
receiver
,
member
)
¶
Disconnects
signal
in object
sender
from
方法
in object
receiver
。返回
true
if the connection is successfully broken; otherwise returns
false
.
A signal-slot connection is removed when either of the objects involved are destroyed.
is typically used in three ways, as the following examples demonstrate.
Disconnect everything connected to an object’s signals:
disconnect(myObject, 0, 0, 0)
equivalent to the non-static overloaded function
myObject.disconnect()
Disconnect everything connected to a specific signal:
disconnect(myObject, SIGNAL('mySignal()'), 0, 0)
equivalent to the non-static overloaded function
myObject.disconnect(SIGNAL('mySignal()'))
Disconnect a specific receiver:
disconnect(myObject, 0, myReceiver, 0)
equivalent to the non-static overloaded function
myObject.disconnect(myReceiver)
None
may be used as a wildcard, meaning “any signal”, “any receiving object”, or “any slot in the receiving object”, respectively.
sender
可能从不是
None
. (You cannot disconnect signals from more than one object in a single call.)
若
signal
is
None
, it disconnects
receiver
and
方法
from any signal. If not, only the specified signal is disconnected.
若
receiver
is
None
, it disconnects anything connected to
signal
. If not, slots in objects other than
receiver
are not disconnected.
若
方法
is
None
, it disconnects anything that is connected to
receiver
. If not, only slots named
方法
will be disconnected, and all other slots are left alone. The
方法
必须是
None
if
receiver
is left out, so you cannot disconnect a specifically-named slot on all objects.
另请参阅
PySide2.QtCore.QObject.
disconnect
(
sender
,
signal
,
receiver
,
member
)
¶
sender
–
QObject
signal
–
QMetaMethod
receiver
–
QObject
member
–
QMetaMethod
bool
PySide2.QtCore.QObject.
disconnect
(
arg__1
,
arg__2
,
arg__3
)
¶
arg__1
–
QObject
arg__2 – str
arg__3
–
PyCallable
bool
PySide2.QtCore.QObject.
disconnect
(
arg__1
)
¶
arg__1
–
Connection
bool
Disconnect a connection.
若
connection
is invalid or has already been disconnected, do nothing and return false.
另请参阅
PySide2.QtCore.QObject.
disconnectNotify
(
signal
)
¶
signal
–
QMetaMethod
This virtual function is called when something has been disconnected from
signal
in this object.
见
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
None
), is only called once, and the
signal
will be an invalid
QMetaMethod
(
isValid()
返回
false
).
警告
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.
PySide2.QtCore.QObject.
dumpObjectInfo
(
)
¶
将有关此对象的信号连接等信息转储到调试输出。
注意
在 Qt 5.9 之前,此函数不是 const。
另请参阅
PySide2.QtCore.QObject.
dumpObjectTree
(
)
¶
将子级树转储到调试输出。
注意
在 Qt 5.9 之前,此函数不是 const。
另请参阅
PySide2.QtCore.QObject.
dynamicPropertyNames
(
)
¶
Returns the names of all properties that were dynamically added to the object using
setProperty()
.
PySide2.QtCore.QObject.
emit
(
arg__1
,
arg__2
)
¶
arg__1 – str
arg__2 – :class:``
bool
PySide2.QtCore.QObject.
event
(
event
)
¶
event
–
QEvent
bool
此虚函数接收对象事件并返回 true,若事件
e
被识别并被处理。
The function can be reimplemented to customize the behavior of an object.
确保调用父级事件类实现,为所有未处理事件。
范例:
class MyClass : public QWidget
{
Q_OBJECT
public:
MyClass(QWidget *parent = nullptr);
~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);
}
};
PySide2.QtCore.QObject.
eventFilter
(
watched
,
event
)
¶
过滤事件,若此对象已被安装成事件过滤器为
watched
对象。
在此函数的重实现中,若希望过滤
event
即:停止进一步处理,返回 true;否则返回 false。
范例:
class MainWindow(QMainWindow):
def __init__(self):
self.textEdit = QTextEdit()
setCentralWidget(self.textEdit)
textEdit.installEventFilter(self)
def eventFilter(self, obj, event):
if obj == textEdit:
if event.type() == QEvent.KeyPress:
keyEvent = event
print("Ate key press", keyEvent.key())
return true
else:
return false
else:
# pass the event on to the parent class
return QMainWindow.eventFilter(self, obj, event)
Notice in the example above that unhandled events are passed to the base class’s function, since the base class might have reimplemented for its own internal purposes.
某些事件,如
ShortcutOverride
必须被明确接受 (通过调用
accept()
) 为阻止传播。
警告
若在此函数中删除接收者对象,确保返回 true。否则,Qt 将把事件转发给被删除对象,且程序可能崩溃。
另请参阅
PySide2.QtCore.QObject.
findChild
(
arg__1
[
,
arg__2=""
]
)
¶
arg__1
–
PyTypeObject
arg__2 – unicode
PyObject
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")
PySide2.QtCore.QObject.
findChildren
(
arg__1
,
arg__2
)
¶
arg__1
–
PyTypeObject
arg__2
–
QRegExp
PySequence
PySide2.QtCore.QObject.
findChildren
(
arg__1
[
,
arg__2=""
]
)
¶
arg__1
–
PyTypeObject
arg__2 – unicode
PySequence
Like the method findChild , the first parameter should be the child’s type.
PySide2.QtCore.QObject.
继承
(
classname
)
¶
classname – str
bool
返回
true
若此对象是类实例,继承
className
或
QObject
子类,继承
className
;否则返回
false
.
类被认为继承本身。
范例:
timer = QTimer() # QTimer inherits QObject
timer.inherits("QTimer") # returns true
timer.inherits("QObject") # returns true
timer.inherits("QAbstractButton") # returns false
# QLayout inherits QObject and QLayoutItem
layout = QLayout()
layout.inherits("QObject") # returns true
layout.inherits("QLayoutItem") # returns false
若为铸造目的需要确定对象是否为特定类的实例,考虑使用
qobject_cast
<Type *>(object) instead.
另请参阅
metaObject()
qobject_cast()
PySide2.QtCore.QObject.
installEventFilter
(
filterObj
)
¶
filterObj
–
QObject
安装事件过滤器
filterObj
在此对象。例如:
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
filterObj
接收事件凭借其
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:
class KeyPressEater(QObject):
def eventFilter(self, obj, event):
if event.type() == QEvent.KeyPress:
print("Ate key press", event.key())
return True
else:
# standard event processing
return QObject.eventFilter(self, 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)
QShortcut
class, for example, uses this technique to intercept shortcut key presses.
警告
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).
PySide2.QtCore.QObject.
isSignalConnected
(
signal
)
¶
signal
–
QMetaMethod
bool
返回
true
若
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.
static const QMetaMethod valueChangedSignal = QMetaMethod::fromSignal(&MyObject::valueChanged);
if (isSignalConnected(valueChangedSignal)) {
QByteArray data;
data = get_the_value(); // expensive operation
emit valueChanged(data);
}
As the code snippet above illustrates, you can use this function to avoid emitting a signal that nobody listens to.
警告
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.
PySide2.QtCore.QObject.
isWidgetType
(
)
¶
bool
返回
true
if the object is a widget; otherwise returns
false
.
调用此函数相当于调用
inherits("QWidget")
,除了它更快。
PySide2.QtCore.QObject.
isWindowType
(
)
¶
bool
返回
true
若对象是窗口;否则返回
false
.
调用此函数相当于调用
inherits("QWindow")
,除了它更快。
PySide2.QtCore.QObject.
killTimer
(
id
)
¶
id
–
int
杀除计时器采用计时器标识符,
id
.
计时器标识符被返回通过
startTimer()
when a timer event is started.
另请参阅
PySide2.QtCore.QObject.
metaObject
(
)
¶
返回指向此对象的元对象的指针。
A meta-object contains information about a class that inherits
QObject
, e.g. class name, superclass name, properties, signals and slots. Every
QObject
subclass that contains the
Q_OBJECT
macro 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 .
范例:
obj = QPushButton()
obj.metaObject().className() # returns "QPushButton"
QPushButton.staticMetaObject.className() # returns "QPushButton"
另请参阅
staticMetaObject
PySide2.QtCore.QObject.
moveToThread
(
thread
)
¶
thread
–
QThread
更改此对象及其子级的线程亲缘关系。对象无法被移动,若它有父级。事件处理将继续在
targetThread
.
To move an object to the main thread, use
instance()
to retrieve a pointer to the current application, and then use
thread()
to retrieve the thread in which the application lives. For example:
myObject.moveToThread(QApplication.instance().thread())
若
targetThread
is
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
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
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.
警告
此函数是 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.
另请参阅
PySide2.QtCore.QObject.
objectName
(
)
¶
unicode
另请参阅
PySide2.QtCore.QObject.
parent
(
)
¶
返回指向父级对象的指针。
另请参阅
PySide2.QtCore.QObject.
特性
(
name
)
¶
name – str
object
Returns the value of the object’s
name
特性。
返回的变体是无效的,若没有这样的特性存在。
所有可用特性的有关信息,提供透过
metaObject()
and
dynamicPropertyNames()
.
另请参阅
setProperty()
isValid()
metaObject()
dynamicPropertyNames()
PySide2.QtCore.QObject.
receivers
(
signal
)
¶
signal – str
int
返回接收者数为连接到
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()')) > 0:
data = get_the_value() # expensive operation
self.valueChanged(data)
警告
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.
另请参阅
PySide2.QtCore.QObject.
registerUserData
(
)
¶
uint
注意
此函数被弃用。
PySide2.QtCore.QObject.
removeEventFilter
(
obj
)
¶
obj
–
QObject
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()
函数)。
PySide2.QtCore.QObject.
sender
(
)
¶
返回发送信号的对象指针,若在由信号激活的槽中调用;否则它返回
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.
警告
此函数违反模块化面向对象原则。不管怎样,访问发送器可能很有用,当多个信号连接到单个槽时。
警告
如上所述,此函数的返回值无效,当槽被调用凭借
DirectConnection
from a thread different from this object’s thread. Do not use this function in this type of scenario.
另请参阅
PySide2.QtCore.QObject.
senderSignalIndex
(
)
¶
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.
警告
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
DirectConnection
from a thread different from this object’s thread. Do not use this function in this type of scenario.
PySide2.QtCore.QObject.
setObjectName
(
name
)
¶
name – unicode
另请参阅
PySide2.QtCore.QObject.
setProperty
(
name
,
value
)
¶
name – str
value – object
bool
Sets the value of the object’s
name
特性到
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.
所有可用特性的有关信息,提供透过
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.
注意
Dynamic properties starting with “_q_” are reserved for internal purposes.
PySide2.QtCore.QObject.
signalsBlocked
(
)
¶
bool
返回
true
若信号被阻塞;否则返回
false
.
信号不被阻塞,默认情况下。
PySide2.QtCore.QObject.
startTimer
(
interval
[
,
timerType=Qt.CoarseTimer
]
)
¶
interval
–
int
timerType
–
TimerType
int
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.
虚拟
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
timerId()
can be used to find out which timer was activated.
范例:
class MyObject(QObject):
def __init__(self, parent):
QObject.__init__(self, parent)
self.startTimer(50) # 50-millisecond timer
self.startTimer(1000) # 1-second timer
self.startTimer(60000) # 1-minute timer
def timerEvent(self, event):
print("Timer ID:", event.timerId())
注意:
QTimer
‘s accuracy depends on the underlying operating system and hardware. The
timerType
argument allows you to customize the accuracy of the timer. See
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.
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.
PySide2.QtCore.QObject.
thread
(
)
¶
返回对象所在的线程。
另请参阅
PySide2.QtCore.QObject.
timerEvent
(
event
)
¶
event
–
QTimerEvent
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
参数。
PySide2.QtCore.QObject.
tr
(
arg__1
[
,
arg__2=0
[
,
arg__3=-1
]
]
)
¶
arg__1 – str
arg__2 – str
arg__3
–
int
unicode