source: trunk/doc/src/snippets/code/doc_src_qaxserver.qdoc@ 651

Last change on this file since 651 was 651, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 5.3 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the documentation of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42//! [0]
43TEMPLATE = app
44CONFIG += qaxserver
45
46RC_FILE = qaxserver.rc
47...
48//! [0]
49
50
51//! [1]
52TEMPLATE = lib
53CONFIG += qaxserver dll
54
55DEF_FILE = qaxserver.def
56RC_FILE = qaxserver.rc
57...
58//! [1]
59
60
61//! [2]
62TEMPLATE = lib
63VERSION = 2.5
64...
65//! [2]
66
67
68//! [3]
69#include <QWidget>
70
71class MyActiveX : public QWidget
72{
73 Q_OBJECT
74//! [3]
75
76
77//! [4]
78Q_CLASSINFO("ClassID", "{1D9928BD-4453-4bdd-903D-E525ED17FDE5}")
79Q_CLASSINFO("InterfaceID", "{99F6860E-2C5A-42ec-87F2-43396F4BE389}")
80Q_CLASSINFO("EventsID", "{0A3E9F27-E4F1-45bb-9E47-63099BCCD0E3}")
81//! [4]
82
83
84//! [5]
85Q_PROPERTY(int value READ value WRITE setValue)
86//! [5]
87
88
89//! [6]
90public:
91 MyActiveX(QWidget *parent = 0)
92 ...
93
94 int value() const;
95
96public slots:
97 void setValue(int v);
98 ...
99
100signals:
101 void valueChange(int v);
102 ...
103
104};
105//! [6]
106
107
108//! [7]
109#include <QAxBindable>
110#include <QWidget>
111
112class MyActiveX : public QWidget, public QAxBindable
113{
114 Q_OBJECT
115//! [7]
116
117
118//! [8]
119QAXFACTORY_BEGIN("{ad90301a-849e-4e8b-9a91-0a6dc5f6461f}",
120 "{a8f21901-7ff7-4f6a-b939-789620c03d83}")
121 QAXCLASS(MyWidget)
122 QAXCLASS(MyWidget2)
123 QAXTYPE(MySubType)
124QAXFACTORY_END()
125//! [8]
126
127
128//! [9]
129#include <QApplication>
130#include <QAxFactory>
131
132int main(int argc, char *argv[])
133{
134 QApplication app(argc, argv);
135 if (!QAxFactory::isServer()) {
136 // create and show main window
137 }
138 return app.exec();
139}
140//! [9]
141
142
143//! [10]
144MyFactory(const QUuid &, const QUuid &);
145//! [10]
146
147
148//! [11]
149HMODULE dll = LoadLibrary("myserver.dll");
150typedef HRESULT(__stdcall *DllRegisterServerProc)();
151DllRegisterServerProc DllRegisterServer =
152 (DllRegisterServerProc)GetProcAddress(dll, "DllRegisterServer");
153
154HRESULT res = E_FAIL;
155if (DllRegisterServer)
156 res = DllRegisterServer();
157if (res != S_OK)
158 // error handling
159//! [11]
160
161
162//! [12]
163cabarc N simpleax.cab simpleax.exe simple.inf
164//! [12]
165
166
167//! [13]
168<object ID="MyActiveX1" CLASSID="CLSID:ad90301a-849e-4e8b-9a91-0a6dc5f6461f">
169 ...
170<\object>
171//! [13]
172
173
174//! [14]
175<object ID=...>
176 <param name="name" value="value">
177<\object>
178//! [14]
179
180
181//! [15]
182class MyActiveX : public QWidget
183{
184 Q_OBJECT
185 Q_CLASSINFO("Version", "2.0")
186 Q_CLASSINFO("ClassID", "{7a4cffd8-cbcd-4ae9-ae7e-343e1e5710df}")
187 Q_CLASSINFO("InterfaceID", "{6fb035bf-8019-48d8-be51-ef05427d8994}")
188 Q_CLASSINFO("EventsID", "{c42fffdf-6557-47c9-817a-2da2228bc29c}")
189 Q_CLASSINFO("Insertable", "yes")
190 Q_CLASSINFO("ToSuperClass", "MyActiveX")
191 Q_PROPERTY(...)
192
193public:
194 MyActiveX(QWidget *parent = 0);
195
196 ...
197};
198//! [15]
199
200
201//! [16]
202class MyLicensedControl : public QWidget
203{
204 Q_OBJECT
205 Q_CLASSINFO("LicenseKey", "<key string>")
206 ...
207};