summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/qaxfactory.3qt
blob: a1538b20db30075f2f2553f3aba0ff31c61efb3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
'\" t
.TH QAxFactory 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA.  All rights reserved.  See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QAxFactory \- Defines a factory for the creation of COM components
.SH SYNOPSIS
This class is part of the \fBQt ActiveQt Extension\fR.
.PP
\fC#include <qaxfactory.h>\fR
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQAxFactory\fR ( const QUuid & libid, const QUuid & appid )"
.br
.ti -1c
.BI "virtual \fB~QAxFactory\fR ()"
.br
.ti -1c
.BI "virtual QStringList \fBfeatureList\fR () const = 0"
.br
.ti -1c
.BI "virtual QWidget * \fBcreate\fR ( const QString & key, QWidget * parent = 0, const char * name = 0 )"
.br
.ti -1c
.BI "virtual QObject * \fBcreateObject\fR ( const QString & key, QObject * parent = 0, const char * name = 0 )"
.br
.ti -1c
.BI "virtual QMetaObject * \fBmetaObject\fR ( const QString & key ) const"
.br
.ti -1c
.BI "virtual bool \fBcreateObjectWrapper\fR ( QObject * object, IDispatch ** wrapper )"
.br
.ti -1c
.BI "virtual QUuid \fBclassID\fR ( const QString & key ) const"
.br
.ti -1c
.BI "virtual QUuid \fBinterfaceID\fR ( const QString & key ) const"
.br
.ti -1c
.BI "virtual QUuid \fBeventsID\fR ( const QString & key ) const"
.br
.ti -1c
.BI "virtual QUuid \fBtypeLibID\fR () const"
.br
.ti -1c
.BI "virtual QUuid \fBappID\fR () const"
.br
.ti -1c
.BI "virtual void \fBregisterClass\fR ( const QString & key, QSettings * settings ) const"
.br
.ti -1c
.BI "virtual void \fBunregisterClass\fR ( const QString & key, QSettings * settings ) const"
.br
.ti -1c
.BI "virtual bool \fBvalidateLicenseKey\fR ( const QString & key, const QString & licenseKey ) const"
.br
.ti -1c
.BI "virtual QString \fBexposeToSuperClass\fR ( const QString & key ) const"
.br
.ti -1c
.BI "virtual bool \fBstayTopLevel\fR ( const QString & key ) const"
.br
.ti -1c
.BI "virtual bool \fBhasStockEvents\fR ( const QString & key ) const"
.br
.ti -1c
.BI "virtual bool \fBisService\fR () const"
.br
.ti -1c
.BI "enum \fBServerType\fR { SingleInstance, MultipleInstances }"
.br
.in -1c
.SS "Static Public Members"
.in +1c
.ti -1c
.BI "bool \fBisServer\fR ()"
.br
.ti -1c
.BI "QString \fBserverDirPath\fR ()"
.br
.ti -1c
.BI "QString \fBserverFilePath\fR ()"
.br
.ti -1c
.BI "bool \fBstartServer\fR ( ServerType type = MultipleInstances )"
.br
.ti -1c
.BI "bool \fBstopServer\fR ()"
.br
.in -1c
.SH DESCRIPTION
This class is defined in the \fBQt ActiveQt Extension\fR, which can be found in the \fCqt/extensions\fR directory. It is not included in the main Qt API.
.PP
The QAxFactory class defines a factory for the creation of COM components.
.PP

.PP
Implement this factory once in your ActiveX server to provide information about the components the server can create. If your server supports just a single ActiveX control, you can use the default factory implementation instead of implementing the factory yourself. Use the QAXFACTORY_DEFAULT macro in any implementation file (e.g. main.cpp) to instantiate and export the default factory:
.PP
.nf
.br
    #include <ntqapplication.h>
.br
    #include <qaxfactory.h>
.br
.br
    #include "theactivex.h"
.br
.br
    QAXFACTORY_DEFAULT(
.br
        TheActiveX,                               // widget class
.br
        "{01234567-89AB-CDEF-0123-456789ABCDEF}", // class ID
.br
        "{01234567-89AB-CDEF-0123-456789ABCDEF}", // interface ID
.br
        "{01234567-89AB-CDEF-0123-456789ABCDEF}", // event interface ID
.br
        "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
.br
        "{01234567-89AB-CDEF-0123-456789ABCDEF}"  // application ID
.br
        )
.br
.fi
.PP
If you implement your own factory reimplement the pure virtual functions, provide the unique identifiers for the ActiveX controls, and use the QAXFACTORY_EXPORT macro to instantiate and export it:
.PP
.nf
.br
    QStringList ActiveQtFactory::featureList() const
.br
    {
.br
        QStringList list;
.br
        list << "ActiveX1";
.br
        list << "ActiveX2";
.br
        ...
.br
        return list;
.br
    }
.br
.br
    QWidget *ActiveQtFactory::create( const QString &key, QWidget *parent, const char *name )
.br
    {
.br
        if ( key == "ActiveX1" )
.br
            return new ActiveX1( parent, name );
.br
        if ( key == "ActiveX2" )
.br
            return new ActiveX2( parent, name );
.br
        ...
.br
        return 0;
.br
    }
.br
.br
    QUuid ActiveQtFactory::classID( const QString &key ) const
.br
    {
.br
        if ( key == "ActiveX1" )
.br
            return "{01234567-89AB-CDEF-0123-456789ABCDEF}";
.br
        ...
.br
        return QUuid();
.br
    }
.br
.br
    QUuid ActiveQtFactory::interfaceID( const QString &key ) const
.br
    {
.br
        if ( key == "ActiveX1" )
.br
            return "{01234567-89AB-CDEF-0123-456789ABCDEF}";
.br
        ...
.br
        return QUuid();
.br
    }
.br
.br
    QUuid ActiveQtFactory::eventsID( const QString &key ) const
.br
    {
.br
        if ( key == "ActiveX1" )
.br
            return "{01234567-89AB-CDEF-0123-456789ABCDEF}";
.br
        ...
.br
        return QUuid();
.br
    }
.br
.br
    QAXFACTORY_EXPORT(
.br
        MyFactory,                                // factory class
.br
        "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
.br
        "{01234567-89AB-CDEF-0123-456789ABCDEF}"  // application ID
.br
        )
.br
.fi
.PP
If you use the \fCQ_CLASSINFO\fR macro to provide the unique identifiers or other attributes for your class you can use the QAXFACTORY_BEGIN, QAXCLASS and QAXFACTORY_END macros to expose one or more classes as COM objects.
.PP
.nf
.br
    QAXFACTORY_BEGIN(
.br
        "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
.br
        "{01234567-89AB-CDEF-0123-456789ABCDEF}"  // application ID
.br
    )
.br
        QAXCLASS(Class1)
.br
        QAXCLASS(Class2)
.br
    QAXFACTORY_END()
.br
.fi
.PP
Only one QAxFactory implementation may be instantiated and exported by an ActiveX server application. This instance is accessible through the global qAxFactory() function.
.PP
A factory can also reimplement the registerClass() and unregisterClass() functions to set additional flags for an ActiveX control in the registry. To limit the number of methods or properties a widget class exposes from its parent classes reimplement exposeToSuperClass().
.SS "Member Type Documentation"
.SH "QAxFactory::ServerType"
This enum specifies the different types of servers that can be started with startServer.
.TP
\fCQAxFactory::SingleInstance\fR - The server can create only one instance of each supplied class.
.TP
\fCQAxFactory::MultipleInstances\fR - The server can create multiple instances of each supplied class.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QAxFactory::QAxFactory ( const QUuid & libid, const QUuid & appid )"
Constructs a QAxFactory object that returns \fIlibid\fR and \fIappid\fR in the implementation of the respective interface functions.
.SH "QAxFactory::~QAxFactory ()\fC [virtual]\fR"
Destroys the QAxFactory object.
.SH "QUuid QAxFactory::appID () const\fC [virtual]\fR"
Reimplement this function to return the ActiveX server's application identifier.
.SH "QUuid QAxFactory::classID ( const QString & key ) const\fC [virtual]\fR"
Reimplement this function to return the class identifier for each \fIkey\fR returned by the featureList() implementation, or an empty QUuid if this factory doesn't support the value of \fIkey\fR.
.PP
The default implementation interprets \fIkey\fR as the class name, and returns the value of the Q_CLASSINFO entry "ClassID".
.SH "QWidget * QAxFactory::create ( const QString & key, QWidget * parent = 0, const char * name = 0 )\fC [virtual]\fR"
Reimplement this function to return a new widget for \fIkey\fR. Propagate \fIparent\fR and \fIname\fR to the QWidget constructor. Return 0 if this factory doesn't support the value of \fIkey\fR.
.PP
The returned widget will be exposed as an ActiveX control, e.g. a COM object that can be embedded as a control into applications.
.PP
The default implementation returns 0.
.SH "QObject * QAxFactory::createObject ( const QString & key, QObject * parent = 0, const char * name = 0 )\fC [virtual]\fR"
Reimplement this function to return a new object for \fIkey\fR. Propagate \fIparent\fR and \fIname\fR to the QWidget constructor. Return 0 if this factory doesn't support the value of \fIkey\fR.
.PP
If the object returned is a QWidget it will be exposed as an ActiveX control, otherwise the returned object will be exposed as a COM object.
.PP
The default implementation returns the result QAxFactory::create() if \fIparent\fR is 0 or a widget, otherwise returns 0.
.SH "bool QAxFactory::createObjectWrapper ( QObject * object, IDispatch ** wrapper )\fC [virtual]\fR"
Reimplement this function to provide the COM object for \fIobject\fR in \fIwrapper\fR. Return TRUE if the function was successfull, otherwise return FALSE.
.PP
The default implementation creates a generic automation wrapper based on the meta object information of \fIobject\fR.
.SH "QUuid QAxFactory::eventsID ( const QString & key ) const\fC [virtual]\fR"
Reimplement this function to return the identifier of the event interface for each \fIkey\fR returned by the featureList() implementation, or an empty QUuid if this factory doesn't support the value of \fIkey\fR.
.PP
The default implementation interprets \fIkey\fR as the class name, and returns the value of the Q_CLASSINFO entry "EventsID".
.SH "QString QAxFactory::exposeToSuperClass ( const QString & key ) const\fC [virtual]\fR"
Reimplement this function to return the name of the super class of \fIkey\fR up to which methods and properties should be exposed by the ActiveX control.
.PP
The default implementation interprets \fIkey\fR as the class name, and returns the value of the Q_CLASSINFO entry "ToSuperClass". If no such value is set the null-string is returned, and the functions and properties of all the super classes including QWidget will be exposed.
.PP
To only expose the functions and properties of the class itself, reimplement this function to return \fIkey\fR.
.SH "QStringList QAxFactory::featureList () const\fC [pure virtual]\fR"
Reimplement this function to return a list of the widgets (class names) supported by this factory.
.SH "bool QAxFactory::hasStockEvents ( const QString & key ) const\fC [virtual]\fR"
Reimplement this function to return TRUE if the ActiveX control \fIkey\fR should support the standard ActiveX events
.TP
Click
.TP
DblClick
.TP
KeyDown
.TP
KeyPress
.TP
KeyUp
.TP
MouseDown
.TP
MouseUp
.TP
MouseMove
.PP
The default implementation interprets \fIkey\fR as the class name, and returns TRUE if the value of the Q_CLASSINFO entry "StockEvents" is "yes". Otherwise this function returns FALSE.
.SH "QUuid QAxFactory::interfaceID ( const QString & key ) const\fC [virtual]\fR"
Reimplement this function to return the interface identifier for each \fIkey\fR returned by the featureList() implementation, or an empty QUuid if this factory doesn't support the value of \fIkey\fR.
.PP
The default implementation interprets \fIkey\fR as the class name, and returns the value of the Q_CLASSINFO entry "InterfaceID".
.SH "bool QAxFactory::isServer ()\fC [static]\fR"
Returns TRUE if the application has been started (by COM) as an ActiveX server, otherwise returns FALSE.
.PP
.nf
.br
    int main( int argc, char**argv )
.br
    {
.br
        QApplication app( argc, argv );
.br
.br
        if ( !QAxFactory::isServer() ) {
.br
            // initialize for stand-alone execution
.br
        }
.br
.br
        return app.exec() // standard event processing
.br
    }
.br
.fi
.SH "bool QAxFactory::isService () const\fC [virtual]\fR"
Reimplement this function to return TRUE if the server is running as a persistent service (e.g. an NT service) and should not terminate even when all objects provided have been released.
.PP
The default implementation returns FALSE.
.SH "QMetaObject * QAxFactory::metaObject ( const QString & key ) const\fC [virtual]\fR"
Reimplement this function to return the QMetaObject corresponding to \fIkey\fR, or 0 if this factory doesn't support the value of \fIkey\fR.
.PP
The default implementation returns the QMetaObject for the class \fIkey\fR.
.SH "void QAxFactory::registerClass ( const QString & key, QSettings * settings ) const\fC [virtual]\fR"
Registers additional values for the class \fIkey\fR in the system registry using the \fIsettings\fR object. The standard values have already been registed by the framework, but additional values, e.g. implemented categories, can be added in an implementation of this function.
.PP
.nf
.br
    settings->writeEntry( "/CLSID/" + classID(key) + "/Implemented Categories/{00000000-0000-0000-000000000000}/.", QString::null );
.br
.fi
.PP
If you reimplement this function you must also reimplement unregisterClass() to remove the additional registry values.
.PP
See also QSettings.
.SH "QString QAxFactory::serverDirPath ()\fC [static]\fR"
Returns the directory that contains the server binary.
.PP
For out-of-process servers this is the same as QApplication::applicationDirPath(). For in-process servers that function returns the directory that contains the hosting application.
.SH "QString QAxFactory::serverFilePath ()\fC [static]\fR"
Returns the file path of the server binary.
.PP
For out-of-process servers this is the same as QApplication::applicationFilePath(). For in-process servers that function returns the file path of the hosting application.
.SH "bool QAxFactory::startServer ( ServerType type = MultipleInstances )\fC [static]\fR"
Starts the COM server with \fItype\fR and returns TRUE if successful, otherwise returns FALSE.
.PP
Calling this function if the server is already running (or for an in-process server) does nothing and returns TRUE.
.PP
The server is started automatically with \fItype\fR set to MultipleUse if the server executable has been started with the \fC-activex\fR command line parameter.
.SH "bool QAxFactory::stayTopLevel ( const QString & key ) const\fC [virtual]\fR"
Reimplement this function to return TRUE if the ActiveX control \fIkey\fR should be a top level window, e.g. a dialog. The default implementation returns FALSE.
.SH "bool QAxFactory::stopServer ()\fC [static]\fR"
Stops the COM server and returns TRUE if successful, otherwise returns FALSE.
.PP
Calling this function if the server is not running (or for an in-process server) does nothing and returns TRUE.
.PP
Stopping the server will not invalidate existing objects, but no new objects can be created from the existing server process. Usually COM will start a new server process if additional objects are requested.
.PP
The server is stopped automatically when the main() function returns.
.SH "QUuid QAxFactory::typeLibID () const\fC [virtual]\fR"
Reimplement this function to return the ActiveX server's type library identifier.
.SH "void QAxFactory::unregisterClass ( const QString & key, QSettings * settings ) const\fC [virtual]\fR"
Unregisters any additional values for the class \fIkey\fR from the system registry using the \fIsettings\fR object.
.PP
.nf
.br
    settings->removeEntry( "/CLSID/" + classID(key) + "/Implemented Categories/{00000000-0000-0000-000000000000}/." );
.br
.fi
.PP
See also registerClass() and QSettings.
.SH "bool QAxFactory::validateLicenseKey ( const QString & key, const QString & licenseKey ) const\fC [virtual]\fR"
Reimplement this function to return TRUE if \fIlicenseKey\fR is a valid license for the class \fIkey\fR, or if the current machine is licensed.
.PP
The default implementation returns TRUE if the class \fIkey\fR is not
licensed (ie. no Q_CLASSINFO attribute "LicenseKey"), or if 
\fIlicenseKey\fR matches the value of the "LicenseKey" attribute, or
if the machine is licensed through a .LIC file with the same filename
as this COM server.

.SH "SEE ALSO"
.BR http://doc.trolltech.com/qaxfactory.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech. 
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (qaxfactory.3qt) and the Qt
version (3.3.8).