The QAxBindable 類提供接口介於 QWidget 和 ActiveX 客戶端。 更多...
| 頭: | #include <QAxBindable> |
| qmake: | QT += axserver |
| QAxBindable () | |
| virtual | ~QAxBindable () |
| virtual QAxAggregated * | createAggregate () |
| virtual bool | readData (QIODevice * source , const QString & format ) |
| void | reportError (int code , const QString & src , const QString & desc , const QString & context = QString()) |
| virtual bool | writeData (QIODevice * sink ) |
| IUnknown * | clientSite () const |
| void | propertyChanged (const char * property ) |
| bool | requestPropertyChange (const char * property ) |
The QAxBindable 類提供接口介於 QWidget 和 ActiveX 客戶端。
由此類提供的函數允許 ActiveX 控件將特性改變通信給客戶端應用程序。繼承控件類從 QWidget (直接或間接) 和此類以訪問此類的函數。 元對象編譯器 要求繼承 QWidget 首先。
class MyActiveX : public QWidget, public QAxBindable { Q_OBJECT Q_PROPERTY(int value READ value WRITE setValue) public: MyActiveX(QWidget *parent = 0); ... int value() const; void setValue(int); };
當實現特性寫入函數時,使用 requestPropertyChange () 從 ActiveX 客戶端應用程序獲取更改此特性的權限。當特性改變時,調用 propertyChanged () 通知 ActiveX 客戶端應用程序即將改變。若控件齣現緻命錯誤,使用靜態 reportError () 函數通知客戶端。
使用接口返迴通過 clientSite () 以調用 ActiveX 客戶端。要在 ActiveX 控件實現額外 COM 接口,重實現 createAggregate () 以返迴新對象 QAxAggregated 子類。
The ActiveQt OpenGL 範例展示如何使用 QAxBindable 以實現額外 COM 接口。
另請參閱 QAxAggregated , QAxFactory ,和 ActiveQt 框架 .
構造空的 QAxBindable 對象。
[虛擬]
QAxBindable::
~QAxBindable
()
銷毀 QAxBindable 對象。
[protected]
IUnknown
*QAxBindable::
clientSite
() const
返迴指嚮此 ActiveX 對象的客戶端站點接口的指針,或 null 若未設置客戶端站點。
調用
QueryInterface()
在返迴接口以獲取想要調用的接口。
[虛擬]
QAxAggregated
*QAxBindable::
createAggregate
()
Reimplement this function when you want to implement additional COM interfaces in the ActiveX control, or when you want to provide alternative implementations of COM interfaces. Return a new object of a QAxAggregated 子類。
默認實現返迴 null 指針。
[protected]
void
QAxBindable::
propertyChanged
(const
char
*
property
)
調用此函數以通知托管此 ActiveX 控件的客戶端特性 property 已改變。
通常在特性寫入函數末尾調用此函數。
另請參閱 requestPropertyChange ().
[虛擬]
bool
QAxBindable::
readData
(
QIODevice
*
source
, const
QString
&
format
)
If the COM object supports a MIME type then this function is called to initialize the COM object from the data source in format 。必須打開 source for reading before you can read from it.
返迴 true 指示成功。若函數返迴 false,那麼 ActiveQt will process the data by setting the properties through the meta object system.
若重實現此函數,還必須實現 writeData ()。默認實現什麼都不做並返迴 false。
警告:
ActiveX 控件嵌入 HTML 可以使用
type
and
data
屬性在
對象
tag to read data, or use a list of
param
tags to initialize properties. If
param
tags are used, then Internet Explorer will ignore the
data
attribute, and readData will not be called.
該函數在 Qt 4.1 引入。
另請參閱 writeData ().
Reports an error to the client application. code is a control-defined error code. desc is a human-readable description of the error intended for the application user. src is the name of the source for the error, typically the ActiveX server name. context can be the location of a help file with more information about the error. If context ends with a number in brackets, e.g. [12], this number will be interpreted as the context ID in the help file.
[protected]
bool
QAxBindable::
requestPropertyChange
(const
char
*
property
)
調用此函數請求權限以更改特性 property 從托管此 ActiveX 控件的客戶端。返迴 true 若客戶端允許更改;否則返迴 false。
寫入函數通常會首先調用此函數對於 property ,和廢棄寫入若函數返迴 false。
void MyActiveQt::setText(const QString &text) { if (!requestPropertyChange("text")) return; // update property propertyChanged("text"); }
另請參閱 propertyChanged ().
[虛擬]
bool
QAxBindable::
writeData
(
QIODevice
*
sink
)
若 COM 對象支持 MIME 類型,那麼調用此函數將把 COM 對象存儲到 sink 。必須打開 sink 以供寫入在可以寫入它之前。
返迴 true 指示成功。若函數返迴 false,那麼 ActiveQt 將通過存儲特性值以序列化對象。
若重實現此函數,還必須實現 readData ()。默認實現什麼都不做並返迴 false。
該函數在 Qt 4.1 引入。
另請參閱 readData ().