QAxWidget 類是 QWidget 用於包裹 ActiveX 控件。 更多...
| 頭: | #include <QAxWidget> |
| qmake: | QT += axcontainer |
| 繼承: | QWidget and QAxBase |
| QAxWidget (IUnknown * iface , QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()) | |
| QAxWidget (const QString & c , QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()) | |
| QAxWidget (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 |
A QAxWidget 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
QAxBase
支持數據類型,變為可用 Qt 特性、槽及信號。基類
QAxBase
提供 API 以直接訪問 ActiveX 透過
IUnknown
指針。
QAxWidget is a QWidget 且主要可以這樣使用,如,可以按 Widget 層次結構和布局組織它,或充當事件過濾器。標準 Widget 特性,如 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.
不管怎樣,無法重實現特定 Qt 事件處理程序像 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.
QAxWidget also inherits most of its ActiveX-related functionality from QAxBase ,顯而易見 dynamicCall () 和 querySubObject ().
警告:
可以子類 QAxWidget,但不可以使用
Q_OBJECT
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 QAxWidget as a member of the
QObject
子類。
另請參閱 QAxBase , QAxObject , QAxScript ,和 ActiveQt 框架 .
Creates a QAxWidget that wraps the COM object referenced by iface . parent and f 被傳播給 QWidget 構造函數。
創建 QAxWidget 小部件並初始化 ActiveX 控件 c . parent and f 被傳播給 QWidget 構造函數。
另請參閱 setControl ().
Creates an empty QAxWidget widget and propagates parent and f 到 QWidget 構造函數。要初始化控件,調用 setControl ().
[override virtual]
QAxWidget::
~QAxWidget
()
關閉 ActiveX 控件並銷毀 QAxWidget 小部件,清理所有分配資源。
另請參閱 clear ().
[override virtual protected]
void
QAxWidget::
changeEvent
(
QEvent
*
e
)
重實現: QWidget::changeEvent (QEvent *event).
[override virtual]
void
QAxWidget::
clear
()
重實現: QAxBase::clear ().
關閉 ActiveX 控件。
[override virtual protected]
void
QAxWidget::
connectNotify
(const
QMetaMethod
&
signal
)
重實現: QObject::connectNotify (const QMetaMethod &signal).
[虛擬]
QAxAggregated
*QAxWidget::
createAggregate
()
重實現此函數,當想為 ActiveX 控件客戶端站點實現其它 COM 接口時,或者當想要提供 COM 接口的替代實現時。返迴新對象為 QAxAggregated 子類。
默認實現返迴 null 指針。
[virtual protected]
bool
QAxWidget::
createHostWindow
(
bool
initialized
)
創建 ActiveX 控件客戶端站點,並返迴 true 若可以成功嵌入控件,否則返迴 false。若 initialized 為 true 控件已初始化。
此函數被調用通過 initialize ()。若重實現初始化以定製實際控件的實例化,在重實現中調用此函數可以讓客戶端側默認嵌入控件。創建 ActiveX 控件客戶端站點,並返迴 true 若可以成功嵌入控件,否則返迴 false。
[protected]
bool
QAxWidget::
createHostWindow
(
bool
initialized
, const
QByteArray
&
data
)
創建 ActiveX 控件客戶端站點,並返迴 true 若可以成功嵌入控件,否則返迴 false。若 initialized 為 false 會初始化控件使用 data 。將透過 IPersistStreamInit 或 IPersistStorage 接口初始化控件。
若需要使用自定義數據初始化控件,調用此函數在重實現的 initialize ()。不會調用此函數由默認實現的 initialize ().
該函數在 Qt 4.4 引入。
請求 ActiveX 控製以履行動作 verb 。可能的 verb 的返迴是通過 verbs ().
函數返迴 true 若對象能履行動作,否則返迴 false。
該函數在 Qt 4.1 引入。
[override virtual protected]
bool
QAxWidget::
initialize
(
IUnknown
**
ptr
)
重實現: QAxBase::initialize (IUnknown **ptr).
調用 QAxBase::initialize ( ptr ),並嵌入控件在此 Widget 中通過調用 createHostWindow (false) 若成功。
為在激活前初始化控件,重實現此函數並添加初始化代碼先於調用 createHostWindow (true)。
返迴
true
當成功時,
false
否則。
該函數在 Qt 4.2 引入。
[override virtual]
QSize
QAxWidget::
minimumSizeHint
() const
重實現訪問函數為特性: QWidget::minimumSizeHint .
[override virtual protected]
void
QAxWidget::
resizeEvent
(
QResizeEvent *
)
重實現: QWidget::resizeEvent (QResizeEvent *event).
[override virtual]
QSize
QAxWidget::
sizeHint
() const
重實現訪問函數為特性: QWidget::sizeHint .
[virtual protected]
bool
QAxWidget::
translateKeyEvent
(
int
message
,
int
keycode
) const
重實現此函數,以將某些關鍵事件傳遞給 ActiveX 控件。 message 是指定消息類型的窗口消息標識符 (即 WM_KEYDOWN),和 keycode 是虛擬鍵碼 (即 VK_TAB)。
若函數返迴 true,將鍵事件傳遞給 ActiveX 控件,然後處理事件或將事件傳遞給 Qt。
若函數返迴 false,鍵事件的處理被忽略由 ActiveQt ,即:ActiveX 控件可以處理它 (或不處理它)。
以下情況默認實現返迴 true:
| WM_SYSKEYDOWN | WM_SYSKEYUP | WM_KEYDOWN |
|---|---|---|
| 所有鍵碼 | VK_MENU | VK_TAB、VK_DELETE 和所有非方嚮鍵組閤 VK_SHIFT、VK_CONTROL 或 VK_MENU |
此錶格是對流行 ActiveX 控件 (即 Internet Explorer 和 Microsoft Office 應用程序) 的實驗結果,但對於某些控件,可能要求修改。