1QAxFactory(3qt)                                                QAxFactory(3qt)
2
3
4

NAME

6       QAxFactory - Defines a factory for the creation of COM components
7

SYNOPSIS

9       This class is part of the Qt ActiveQt Extension.
10
11       #include <qaxfactory.h>
12
13   Public Members
14       QAxFactory ( const QUuid & libid, const QUuid & appid )
15       virtual ~QAxFactory ()
16       virtual QStringList featureList () const = 0
17       virtual QWidget * create ( const QString & key, QWidget * parent = 0,
18           const char * name = 0 )
19       virtual QObject * createObject ( const QString & key, QObject * parent
20           = 0, const char * name = 0 )
21       virtual QMetaObject * metaObject ( const QString & key ) const
22       virtual bool createObjectWrapper ( QObject * object, IDispatch **
23           wrapper )
24       virtual QUuid classID ( const QString & key ) const
25       virtual QUuid interfaceID ( const QString & key ) const
26       virtual QUuid eventsID ( const QString & key ) const
27       virtual QUuid typeLibID () const
28       virtual QUuid appID () const
29       virtual void registerClass ( const QString & key, QSettings * settings
30           ) const
31       virtual void unregisterClass ( const QString & key, QSettings *
32           settings ) const
33       virtual bool validateLicenseKey ( const QString & key, const QString &
34           licenseKey ) const
35       virtual QString exposeToSuperClass ( const QString & key ) const
36       virtual bool stayTopLevel ( const QString & key ) const
37       virtual bool hasStockEvents ( const QString & key ) const
38       virtual bool isService () const
39       enum ServerType { SingleInstance, MultipleInstances }
40
41   Static Public Members
42       bool isServer ()
43       QString serverDirPath ()
44       QString serverFilePath ()
45       bool startServer ( ServerType type = MultipleInstances )
46       bool stopServer ()
47

DESCRIPTION

49       This class is defined in the Qt ActiveQt Extension, which can be found
50       in the qt/extensions directory. It is not included in the main Qt API.
51
52       The QAxFactory class defines a factory for the creation of COM
53       components.
54
55       Implement this factory once in your ActiveX server to provide
56       information about the components the server can create. If your server
57       supports just a single ActiveX control, you can use the default factory
58       implementation instead of implementing the factory yourself. Use the
59       QAXFACTORY_DEFAULT macro in any implementation file (e.g. main.cpp) to
60       instantiate and export the default factory:
61
62           #include <qapplication.h>
63           #include <qaxfactory.h>
64           #include "theactivex.h"
65           QAXFACTORY_DEFAULT(
66               TheActiveX,                               // widget class
67               "{01234567-89AB-CDEF-0123-456789ABCDEF}", // class ID
68               "{01234567-89AB-CDEF-0123-456789ABCDEF}", // interface ID
69               "{01234567-89AB-CDEF-0123-456789ABCDEF}", // event interface ID
70               "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
71               "{01234567-89AB-CDEF-0123-456789ABCDEF}"  // application ID
72               )
73
74       If you implement your own factory reimplement the pure virtual
75       functions, provide the unique identifiers for the ActiveX controls, and
76       use the QAXFACTORY_EXPORT macro to instantiate and export it:
77
78           QStringList ActiveQtFactory::featureList() const
79           {
80               QStringList list;
81               list << "ActiveX1";
82               list << "ActiveX2";
83               ...
84               return list;
85           }
86           QWidget *ActiveQtFactory::create( const QString &key, QWidget *parent, const char *name )
87           {
88               if ( key == "ActiveX1" )
89                   return new ActiveX1( parent, name );
90               if ( key == "ActiveX2" )
91                   return new ActiveX2( parent, name );
92               ...
93               return 0;
94           }
95           QUuid ActiveQtFactory::classID( const QString &key ) const
96           {
97               if ( key == "ActiveX1" )
98                   return "{01234567-89AB-CDEF-0123-456789ABCDEF}";
99               ...
100               return QUuid();
101           }
102           QUuid ActiveQtFactory::interfaceID( const QString &key ) const
103           {
104               if ( key == "ActiveX1" )
105                   return "{01234567-89AB-CDEF-0123-456789ABCDEF}";
106               ...
107               return QUuid();
108           }
109           QUuid ActiveQtFactory::eventsID( const QString &key ) const
110           {
111               if ( key == "ActiveX1" )
112                   return "{01234567-89AB-CDEF-0123-456789ABCDEF}";
113               ...
114               return QUuid();
115           }
116           QAXFACTORY_EXPORT(
117               MyFactory,                                // factory class
118               "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
119               "{01234567-89AB-CDEF-0123-456789ABCDEF}"  // application ID
120               )
121
122       If you use the Q_CLASSINFO macro to provide the unique identifiers or
123       other attributes for your class you can use the QAXFACTORY_BEGIN,
124       QAXCLASS and QAXFACTORY_END macros to expose one or more classes as COM
125       objects.
126
127           QAXFACTORY_BEGIN(
128               "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
129               "{01234567-89AB-CDEF-0123-456789ABCDEF}"  // application ID
130           )
131               QAXCLASS(Class1)
132               QAXCLASS(Class2)
133           QAXFACTORY_END()
134
135       Only one QAxFactory implementation may be instantiated and exported by
136       an ActiveX server application. This instance is accessible through the
137       global qAxFactory() function.
138
139       A factory can also reimplement the registerClass() and
140       unregisterClass() functions to set additional flags for an ActiveX
141       control in the registry. To limit the number of methods or properties a
142       widget class exposes from its parent classes reimplement
143       exposeToSuperClass().
144
145   Member Type Documentation

QAxFactory::ServerType

147       This enum specifies the different types of servers that can be started
148       with startServer.
149
150       QAxFactory::SingleInstance - The server can create only one instance of
151       each supplied class.
152
153       QAxFactory::MultipleInstances - The server can create multiple
154       instances of each supplied class.
155

MEMBER FUNCTION DOCUMENTATION

QAxFactory::QAxFactory ( const QUuid & libid, const QUuid & appid )

158       Constructs a QAxFactory object that returns libid and appid in the
159       implementation of the respective interface functions.
160

QAxFactory::~QAxFactory () [virtual]

162       Destroys the QAxFactory object.
163

QUuid QAxFactory::appID () const [virtual]

165       Reimplement this function to return the ActiveX server's application
166       identifier.
167

QUuid QAxFactory::classID ( const QString & key ) const [virtual]

169       Reimplement this function to return the class identifier for each key
170       returned by the featureList() implementation, or an empty QUuid if this
171       factory doesn't support the value of key.
172
173       The default implementation interprets key as the class name, and
174       returns the value of the Q_CLASSINFO entry "ClassID".
175

QWidget * QAxFactory::create ( const QString & key, QWidget * parent = 0,

177       const char * name = 0 ) [virtual]
178       Reimplement this function to return a new widget for key. Propagate
179       parent and name to the QWidget constructor. Return 0 if this factory
180       doesn't support the value of key.
181
182       The returned widget will be exposed as an ActiveX control, e.g. a COM
183       object that can be embedded as a control into applications.
184
185       The default implementation returns 0.
186

QObject * QAxFactory::createObject ( const QString & key, QObject * parent =

188       0, const char * name = 0 ) [virtual]
189       Reimplement this function to return a new object for key. Propagate
190       parent and name to the QWidget constructor. Return 0 if this factory
191       doesn't support the value of key.
192
193       If the object returned is a QWidget it will be exposed as an ActiveX
194       control, otherwise the returned object will be exposed as a COM object.
195
196       The default implementation returns the result QAxFactory::create() if
197       parent is 0 or a widget, otherwise returns 0.
198

bool QAxFactory::createObjectWrapper ( QObject * object, IDispatch ** wrapper

200       ) [virtual]
201       Reimplement this function to provide the COM object for object in
202       wrapper. Return TRUE if the function was successfull, otherwise return
203       FALSE.
204
205       The default implementation creates a generic automation wrapper based
206       on the meta object information of object.
207

QUuid QAxFactory::eventsID ( const QString & key ) const [virtual]

209       Reimplement this function to return the identifier of the event
210       interface for each key returned by the featureList() implementation, or
211       an empty QUuid if this factory doesn't support the value of key.
212
213       The default implementation interprets key as the class name, and
214       returns the value of the Q_CLASSINFO entry "EventsID".
215

QString QAxFactory::exposeToSuperClass ( const QString & key ) const [virtual]

217
218       Reimplement this function to return the name of the super class of key
219       up to which methods and properties should be exposed by the ActiveX
220       control.
221
222       The default implementation interprets key as the class name, and
223       returns the value of the Q_CLASSINFO entry "ToSuperClass". If no such
224       value is set the null-string is returned, and the functions and
225       properties of all the super classes including QWidget will be exposed.
226
227       To only expose the functions and properties of the class itself,
228       reimplement this function to return key.
229

QStringList QAxFactory::featureList () const [pure virtual]

231       Reimplement this function to return a list of the widgets (class names)
232       supported by this factory.
233

bool QAxFactory::hasStockEvents ( const QString & key ) const [virtual]

235       Reimplement this function to return TRUE if the ActiveX control key
236       should support the standard ActiveX events
237
238       Click
239
240       DblClick
241
242       KeyDown
243
244       KeyPress
245
246       KeyUp
247
248       MouseDown
249
250       MouseUp
251
252       MouseMove
253
254       The default implementation interprets key as the class name, and
255       returns TRUE if the value of the Q_CLASSINFO entry "StockEvents" is
256       "yes". Otherwise this function returns FALSE.
257

QUuid QAxFactory::interfaceID ( const QString & key ) const [virtual]

259       Reimplement this function to return the interface identifier for each
260       key returned by the featureList() implementation, or an empty QUuid if
261       this factory doesn't support the value of key.
262
263       The default implementation interprets key as the class name, and
264       returns the value of the Q_CLASSINFO entry "InterfaceID".
265

bool QAxFactory::isServer () [static]

267       Returns TRUE if the application has been started (by COM) as an ActiveX
268       server, otherwise returns FALSE.
269
270           int main( int argc, char**argv )
271           {
272               QApplication app( argc, argv );
273               if ( !QAxFactory::isServer() ) {
274                   // initialize for stand-alone execution
275               }
276               return app.exec() // standard event processing
277           }
278

bool QAxFactory::isService () const [virtual]

280       Reimplement this function to return TRUE if the server is running as a
281       persistent service (e.g. an NT service) and should not terminate even
282       when all objects provided have been released.
283
284       The default implementation returns FALSE.
285

QMetaObject * QAxFactory::metaObject ( const QString & key ) const [virtual]

287       Reimplement this function to return the QMetaObject corresponding to
288       key, or 0 if this factory doesn't support the value of key.
289
290       The default implementation returns the QMetaObject for the class key.
291

void QAxFactory::registerClass ( const QString & key, QSettings * settings )

293       const [virtual]
294       Registers additional values for the class key in the system registry
295       using the settings object. The standard values have already been
296       registed by the framework, but additional values, e.g. implemented
297       categories, can be added in an implementation of this function.
298
299           settings->writeEntry( "/CLSID/" + classID(key) + "/Implemented Categories/{00000000-0000-0000-000000000000}/.", QString::null );
300
301       If you reimplement this function you must also reimplement
302       unregisterClass() to remove the additional registry values.
303
304       See also QSettings.
305

QString QAxFactory::serverDirPath () [static]

307       Returns the directory that contains the server binary.
308
309       For out-of-process servers this is the same as
310       QApplication::applicationDirPath(). For in-process servers that
311       function returns the directory that contains the hosting application.
312

QString QAxFactory::serverFilePath () [static]

314       Returns the file path of the server binary.
315
316       For out-of-process servers this is the same as
317       QApplication::applicationFilePath(). For in-process servers that
318       function returns the file path of the hosting application.
319

bool QAxFactory::startServer ( ServerType type = MultipleInstances ) [static]

321       Starts the COM server with type and returns TRUE if successful,
322       otherwise returns FALSE.
323
324       Calling this function if the server is already running (or for an in-
325       process server) does nothing and returns TRUE.
326
327       The server is started automatically with type set to MultipleUse if the
328       server executable has been started with the -activex command line
329       parameter.
330

bool QAxFactory::stayTopLevel ( const QString & key ) const [virtual]

332       Reimplement this function to return TRUE if the ActiveX control key
333       should be a top level window, e.g. a dialog. The default implementation
334       returns FALSE.
335

bool QAxFactory::stopServer () [static]

337       Stops the COM server and returns TRUE if successful, otherwise returns
338       FALSE.
339
340       Calling this function if the server is not running (or for an in-
341       process server) does nothing and returns TRUE.
342
343       Stopping the server will not invalidate existing objects, but no new
344       objects can be created from the existing server process. Usually COM
345       will start a new server process if additional objects are requested.
346
347       The server is stopped automatically when the main() function returns.
348

QUuid QAxFactory::typeLibID () const [virtual]

350       Reimplement this function to return the ActiveX server's type library
351       identifier.
352

void QAxFactory::unregisterClass ( const QString & key, QSettings * settings )

354       const [virtual]
355       Unregisters any additional values for the class key from the system
356       registry using the settings object.
357
358           settings->removeEntry( "/CLSID/" + classID(key) + "/Implemented Categories/{00000000-0000-0000-000000000000}/." );
359
360       See also registerClass() and QSettings.
361

bool QAxFactory::validateLicenseKey ( const QString & key, const QString &

363       licenseKey ) const [virtual]
364       Reimplement this function to return TRUE if licenseKey is a valid
365       license for the class key, or if the current machine is licensed.
366
367       The default implementation returns TRUE if the class key is not
368       licensed (ie. no Q_CLASSINFO attribute "LicenseKey"), or if licenseKey
369       matches the value of the "LicenseKey" attribute, or if the machine is
370       licensed through a .LIC file with the same filename as this COM server.
371
372

SEE ALSO

374       http://doc.trolltech.com/qaxfactory.html
375       http://www.trolltech.com/faq/tech.html
376
378       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
379       license file included in the distribution for a complete license
380       statement.
381

AUTHOR

383       Generated automatically from the source code.
384

BUGS

386       If you find a bug in Qt, please report it as described in
387       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
388       help you. Thank you.
389
390       The definitive Qt documentation is provided in HTML format; it is
391       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
392       web browser. This man page is provided as a convenience for those users
393       who prefer man pages, although this format is not officially supported
394       by Trolltech.
395
396       If you find errors in this manual page, please report them to qt-
397       bugs@trolltech.com.  Please include the name of the manual page
398       (qaxfactory.3qt) and the Qt version (3.3.8).
399
400
401
402Trolltech AS                    2 February 2007                QAxFactory(3qt)
Impressum