Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The QAxFactory class defines a factory for the creation of COM components. More...
This class is part of the Qt ActiveQt Extension.
#include <qaxfactory.h>
This class is defined in the Qt ActiveQt Extension, which can be found in the qt/extensions directory. It is not included in the main Qt API.
The QAxFactory class defines a factory for the creation of COM components.
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:
#include <qapplication.h> #include <qaxfactory.h> #include "theactivex.h" QAXFACTORY_DEFAULT( TheActiveX, // widget class "{01234567-89AB-CDEF-0123-456789ABCDEF}", // class ID "{01234567-89AB-CDEF-0123-456789ABCDEF}", // interface ID "{01234567-89AB-CDEF-0123-456789ABCDEF}", // event interface ID "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID "{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID )
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:
QStringList ActiveQtFactory::featureList() const { QStringList list; list << "ActiveX1"; list << "ActiveX2"; ... return list; } QWidget *ActiveQtFactory::create( const QString &key, QWidget *parent, const char *name ) { if ( key == "ActiveX1" ) return new ActiveX1( parent, name ); if ( key == "ActiveX2" ) return new ActiveX2( parent, name ); ... return 0; } QUuid ActiveQtFactory::classID( const QString &key ) const { if ( key == "ActiveX1" ) return "{01234567-89AB-CDEF-0123-456789ABCDEF}"; ... return QUuid(); } QUuid ActiveQtFactory::interfaceID( const QString &key ) const { if ( key == "ActiveX1" ) return "{01234567-89AB-CDEF-0123-456789ABCDEF}"; ... return QUuid(); } QUuid ActiveQtFactory::eventsID( const QString &key ) const { if ( key == "ActiveX1" ) return "{01234567-89AB-CDEF-0123-456789ABCDEF}"; ... return QUuid(); } QAXFACTORY_EXPORT( MyFactory, // factory class "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID "{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID )
If you use the Q_CLASSINFO 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.
QAXFACTORY_BEGIN( "{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID "{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID ) QAXCLASS(Class1) QAXCLASS(Class2) QAXFACTORY_END()
Only one QAxFactory implementation may be instantiated and exported by an ActiveX server application. This instance is accessible through the global qAxFactory() function.
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().
This enum specifies the different types of servers that can be started with startServer.
Reimplement this function to return the ActiveX server's application identifier.
The default implementation interprets key as the class name, and returns the value of the Q_CLASSINFO entry "ClassID".
The returned widget will be exposed as an ActiveX control, e.g. a COM object that can be embedded as a control into applications.
The default implementation returns 0.
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.
The default implementation returns the result QAxFactory::create() if parent is 0 or a widget, otherwise returns 0.
Reimplement this function to provide the COM object for object in wrapper. Return TRUE if the function was successfull, otherwise return FALSE.
The default implementation creates a generic automation wrapper based on the meta object information of object.
The default implementation interprets key as the class name, and returns the value of the Q_CLASSINFO entry "EventsID".
The default implementation interprets key 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.
To only expose the functions and properties of the class itself, reimplement this function to return key.
Reimplement this function to return a list of the widgets (class names) supported by this factory.
The default implementation interprets key as the class name, and returns TRUE if the value of the Q_CLASSINFO entry "StockEvents" is "yes". Otherwise this function returns FALSE.
The default implementation interprets key as the class name, and returns the value of the Q_CLASSINFO entry "InterfaceID".
int main( int argc, char**argv ) { QApplication app( argc, argv ); if ( !QAxFactory::isServer() ) { // initialize for stand-alone execution } return app.exec() // standard event processing }
The default implementation returns FALSE.
The default implementation returns the QMetaObject for the class key.
settings->writeEntry( "/CLSID/" + classID(key) + "/Implemented Categories/{00000000-0000-0000-000000000000}/.", QString::null );
If you reimplement this function you must also reimplement unregisterClass() to remove the additional registry values.
See also QSettings.
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.
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.
Starts the COM server with type and returns TRUE if successful, otherwise returns FALSE.
Calling this function if the server is already running (or for an in-process server) does nothing and returns TRUE.
The server is started automatically with type set to MultipleUse if the server executable has been started with the -activex command line parameter.
Stops the COM server and returns TRUE if successful, otherwise returns FALSE.
Calling this function if the server is not running (or for an in-process server) does nothing and returns TRUE.
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.
The server is stopped automatically when the main() function returns.
Reimplement this function to return the ActiveX server's type library identifier.
settings->removeEntry( "/CLSID/" + classID(key) + "/Implemented Categories/{00000000-0000-0000-000000000000}/." );
See also registerClass() and QSettings.
The default implementation returns TRUE if the class key is not licensed (ie. no Q_CLASSINFO attribute "LicenseKey"), or if licenseKey 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.
This file is part of the Qt toolkit. Copyright © 1995-2005 Trolltech. All Rights Reserved.
Copyright © 2005 Trolltech | Trademarks | Qt 3.3.6
|