|QAxWidget (QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags())|
|QAxWidget (const QString & c , QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags())|
|QAxWidget (IUnknown * iface , QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags())|
|virtual||~QAxWidget () override|
|virtual QAxAggregated *||createAggregate ()|
|bool||doVerb (const QString & verb )|
|virtual void||clear () override|
|virtual QSize||minimumSizeHint () const override|
|virtual QSize||sizeHint () const override|
|virtual bool||createHostWindow (bool initialized )|
|bool||createHostWindow (bool initialized , const QByteArray & data )|
|virtual bool||translateKeyEvent (int message , int keycode ) const|
|virtual void||changeEvent (QEvent * e ) override|
|virtual void||connectNotify (const QMetaMethod & signal ) override|
|virtual bool||initialize (IUnknown ** ptr ) override|
|virtual void||resizeEvent ( QResizeEvent * ) override|
can be instantiated as an empty object, with the name of the ActiveX control it should wrap, or with an existing interface pointer to the ActiveX control. The ActiveX control's properties, methods and events which only use
supported data types, become available as Qt properties, slots and signals. The base class
provides an API to access the ActiveX directly through the
QAxWidget 是 QWidget and can mostly be used as such, e.g. it can be organized in a widget hierarchy and layouts or act as an event filter. Standard widget properties, e.g. enabled are supported, but it depends on the ActiveX control to implement support for ambient properties like e.g. palette or font. QAxWidget tries to provide the necessary hints.
However, you cannot reimplement Qt-specific event handlers like mousePressEvent or keyPressEvent and expect them to be called reliably. The embedded control covers the QAxWidget completely, and usually handles the user interface itself. Use control-specific APIs (i.e. listen to the signals of the control), or use standard COM techniques like window procedure subclassing.
You can subclass
, but you cannot use the
macro in the subclass (the generated moc-file will not compile), so you cannot add further signals, slots or properties. This limitation is due to the metaobject information generated in runtime. To work around this problem, aggregate the
as a member of the
另请参阅 setControl ().
Shuts down the ActiveX control and destroys the QAxWidget widget, cleaning up all allocated resources.
另请参阅 clear ().
[override virtual protected]void QAxWidget:: changeEvent ( QEvent * e )
Reimplemented from QWidget::changeEvent ().
Reimplemented from QAxBase::clear ().
Shuts down the ActiveX control.
[override virtual protected]void QAxWidget:: connectNotify (const QMetaMethod & signal )
Reimplemented from QObject::connectNotify ().
[virtual]QAxAggregated *QAxWidget:: createAggregate ()
Reimplement this function when you want to implement additional COM interfaces for the client site of the ActiveX control, or when you want to provide alternative implementations of COM interfaces. Return a new object of a QAxAggregated subclass.
The default implementation returns the null pointer.
Creates the client site for the ActiveX control, and returns true if the control could be embedded successfully, otherwise returns false. If initialized is true the control has already been initialized.
此函数被调用由 initialize (). If you reimplement initialize to customize the actual control instantiation, call this function in your reimplementation to have the control embedded by the default client side. Creates the client site for the ActiveX control, and returns true if the control could be embedded successfully, otherwise returns false.
[protected]bool QAxWidget:: createHostWindow ( bool initialized , const QByteArray & data )
Creates the client site for the ActiveX control, and returns true if the control could be embedded successfully, otherwise returns false. If initialized is false the control will be initialized using the data . The control will be initialized through either IPersistStreamInit or IPersistStorage interface.
This function was introduced in Qt 4.4.
Requests the ActiveX control to perform the action verb . The possible verbs are returned by verbs ().
The function returns true if the object could perform the action, otherwise returns false.
This function was introduced in Qt 4.1.
Reimplemented from QAxBase::initialize ().
To initialize the control before it is activated, reimplement this function and add your initialization code before you call createHostWindow (true).
This function was introduced in Qt 4.2.
[override virtual]QSize QAxWidget:: minimumSizeHint () const
Reimplemented from QWidget::minimumSizeHint ().
Reimplemented from QWidget::resizeEvent ().
[override virtual]QSize QAxWidget:: sizeHint () const
Reimplemented from QWidget::sizeHint ().
Reimplement this function to pass certain key events to the ActiveX control. message is the Window message identifier specifying the message type (ie. WM_KEYDOWN), and keycode is the virtual keycode (ie. VK_TAB).
If the function returns true the key event is passed on to the ActiveX control, which then either processes the event or passes the event on to Qt.
If the function returns false the processing of the key event is ignored by ActiveQt , ie. the ActiveX control might handle it or not.
The default implementation returns true for the following cases:
|All keycodes||VK_MENU||VK_TAB, VK_DELETE and all non-arrow-keys in combination with VK_SHIFT, VK_CONTROL or VK_MENU|
This table is the result of experimenting with popular ActiveX controls, ie. Internet Explorer and Microsoft Office applications, but for some controls it might require modification.