diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2009-03-23 09:18:55 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-03-23 09:18:55 (GMT) |
commit | e5fcad302d86d316390c6b0f62759a067313e8a9 (patch) | |
tree | c2afbf6f1066b6ce261f14341cf6d310e5595bc1 /doc/src/snippets/code/doc_src_qaxserver.qdoc | |
download | Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.zip Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.gz Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.bz2 |
Long live Qt 4.5!
Diffstat (limited to 'doc/src/snippets/code/doc_src_qaxserver.qdoc')
-rw-r--r-- | doc/src/snippets/code/doc_src_qaxserver.qdoc | 223 |
1 files changed, 223 insertions, 0 deletions
diff --git a/doc/src/snippets/code/doc_src_qaxserver.qdoc b/doc/src/snippets/code/doc_src_qaxserver.qdoc new file mode 100644 index 0000000..9b51e66 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qaxserver.qdoc @@ -0,0 +1,223 @@ +//! [0] +TEMPLATE = app +CONFIG += qaxserver + +RC_FILE = qaxserver.rc +... +//! [0] + + +//! [1] +TEMPLATE = lib +CONFIG += qaxserver dll + +DEF_FILE = qaxserver.def +RC_FILE = qaxserver.rc +... +//! [1] + + +//! [2] +TEMPLATE = lib +VERSION = 2.5 +... +//! [2] + + +//! [3] +#include <QWidget> + +class MyActiveX : public QWidget +{ + Q_OBJECT +//! [3] + + +//! [4] +Q_CLASSINFO("ClassID", "{1D9928BD-4453-4bdd-903D-E525ED17FDE5}") +Q_CLASSINFO("InterfaceID", "{99F6860E-2C5A-42ec-87F2-43396F4BE389}") +Q_CLASSINFO("EventsID", "{0A3E9F27-E4F1-45bb-9E47-63099BCCD0E3}") +//! [4] + + +//! [5] +Q_PROPERTY(int value READ value WRITE setValue) +//! [5] + + +//! [6] +public: + MyActiveX(QWidget *parent = 0) + ... + + int value() const; + +public slots: + void setValue(int v); + ... + +signals: + void valueChange(int v); + ... + +}; +//! [6] + + +//! [7] +#include <QAxBindable> +#include <QWidget> + +class MyActiveX : public QWidget, public QAxBindable +{ + Q_OBJECT +//! [7] + + +//! [8] +QAXFACTORY_BEGIN("{ad90301a-849e-4e8b-9a91-0a6dc5f6461f}", + "{a8f21901-7ff7-4f6a-b939-789620c03d83}") + QAXCLASS(MyWidget) + QAXCLASS(MyWidget2) + QAXTYPE(MySubType) +QAXFACTORY_END() +//! [8] + + +//! [9] +#include <QApplication> +#include <QAxFactory> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + if (!QAxFactory::isServer()) { + // create and show main window + } + return app.exec(); +} +//! [9] + + +//! [10] +MyFactory(const QUuid &, const QUuid &); +//! [10] + + +//! [11] +HMODULE dll = LoadLibrary("myserver.dll"); +typedef HRESULT(__stdcall *DllRegisterServerProc)(); +DllRegisterServerProc DllRegisterServer = + (DllRegisterServerProc)GetProcAddress(dll, "DllRegisterServer"); + +HRESULT res = E_FAIL; +if (DllRegisterServer) + res = DllRegisterServer(); +if (res != S_OK) + // error handling +//! [11] + + +//! [12] +cabarc N simpleax.cab simpleax.exe simple.inf +//! [12] + + +//! [13] +<object ID="MyActiveX1" CLASSID="CLSID:ad90301a-849e-4e8b-9a91-0a6dc5f6461f"> + ... +<\object> +//! [13] + + +//! [14] +<object ID=...> + <param name="name" value="value"> +<\object> +//! [14] + + +//! [15] +class MyActiveX : public QWidget +{ + Q_OBJECT + Q_CLASSINFO("Version", "2.0") + Q_CLASSINFO("ClassID", "{7a4cffd8-cbcd-4ae9-ae7e-343e1e5710df}") + Q_CLASSINFO("InterfaceID", "{6fb035bf-8019-48d8-be51-ef05427d8994}") + Q_CLASSINFO("EventsID", "{c42fffdf-6557-47c9-817a-2da2228bc29c}") + Q_CLASSINFO("Insertable", "yes") + Q_CLASSINFO("ToSuperClass", "MyActiveX") + Q_PROPERTY(...) + +public: + MyActiveX(QWidget *parent = 0); + + ... +}; +//! [15] + + +//! [16] +class MyLicensedControl : public QWidget +{ + Q_OBJECT + Q_CLASSINFO("LicenseKey", "<key string>") + ... +}; +//! [16] + + +//! [17] +class AxImpl : public QAxAggregated, public ISomeCOMInterface +{ +public: + AxImpl() {} + + long queryInterface(const QUuid &iid, void **iface); + + // IUnknown + QAXAGG_IUNKNOWN + + // ISomeCOMInterface + ... +} +//! [17] + + +//! [18] +long AxImpl::queryInterface(const QUuid &iid, void **iface) +{ + *iface = 0; + if (iid == IID_ISomeCOMInterface) + *iface = (ISomeCOMInterface *)this; + else + return E_NOINTERFACE; + + AddRef(); + return S_OK; +} +//! [18] + + +//! [19] +HRESULT AxImpl::QueryInterface(REFIID iid, void **iface) +{ + return controllingUnknown()->QueryInterface(iid, iface); +} +//! [19] + + +//! [20] +class MyActiveX : public QWidget, public QAxBindable +{ + Q_OBJECT + +public: + MyActiveX(QWidget *parent); + + QAxAggregated *createAggregate() + { + return new AxImpl(); + } +}; +//! [20] |