QAxFactory(3qt)
π QAxFactory π
okay bestie, welcome to QAxFactory(3qt) β yes that's the manual page name, that's the whole vibe, we're in the Qt docs now π
β¨ NAME β¨
QAxFactory β it defines a factory for the creation of COM components. that's it, that's the girl π«Ά
πΈ SYNOPSIS πΈ
This class is part of the Qt ActiveQt Extension.
#include <qaxfactory.h>
π Public Members
QAxFactory ( const QUuid & libid, const QUuid & appid )virtual ~QAxFactory ()virtual QStringList featureList () const = 0virtual QWidget * create ( const QString & key, QWidget * parent = 0, const char * name = 0 )virtual QObject * createObject ( const QString & key, QObject * parent = 0, const char * name = 0 )virtual QMetaObject * metaObject ( const QString & key ) constvirtual bool createObjectWrapper ( QObject * object, IDispatch ** wrapper )virtual QUuid classID ( const QString & key ) constvirtual QUuid interfaceID ( const QString & key ) constvirtual QUuid eventsID ( const QString & key ) constvirtual QUuid typeLibID () constvirtual QUuid appID () constvirtual void registerClass ( const QString & key, QSettings * settings ) constvirtual void unregisterClass ( const QString & key, QSettings * settings ) constvirtual bool validateLicenseKey ( const QString & key, const QString & licenseKey ) constvirtual QString exposeToSuperClass ( const QString & key ) constvirtual bool stayTopLevel ( const QString & key ) constvirtual bool hasStockEvents ( const QString & key ) constvirtual bool isService () constenum ServerType { SingleInstance, MultipleInstances }
π¦ Static Public Members
bool isServer ()QString serverDirPath ()QString serverFilePath ()bool startServer ( ServerType type = MultipleInstances )bool stopServer ()
π DESCRIPTION π
okay so first thing, important lore: this class is defined in the Qt ActiveQt Extension, which lives in the qt/extensions directory. it is not included in the main Qt API. so don't go looking for it in the main character lineup, she's in the extensions wing π
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. and here's the slay part β 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 oneQAxFactoryimplementation may be instantiated and exported by an ActiveX server application. one. singular. no poly, bestie π This instance is accessible through the globalqAxFactory()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().
π Member Type Documentation π
QAxFactory::ServerType
This enum specifies the different types of servers that can be started with startServer.
QAxFactory::SingleInstanceβ The server can create only one instance of each supplied class. one and done, monogamy era πQAxFactory::MultipleInstancesβ The server can create multiple instances of each supplied class. polyamory era, she contains multitudes β¨
π MEMBER FUNCTION DOCUMENTATION π
QAxFactory::QAxFactory ( const QUuid & libid, const QUuid & appid )
Constructs a QAxFactory object that returns libid and appid in the implementation of the respective interface functions. it's giving constructor, she's built different π«Ά
QAxFactory::~QAxFactory () [virtual]
Destroys the QAxFactory object. rip queen, you served π«‘
QUuid QAxFactory::appID () const [virtual]
Reimplement this function to return the ActiveX server's application identifier. it's her government name fr fr
QUuid QAxFactory::classID ( const QString & key ) const [virtual]
Reimplement this function to return the class identifier for each key returned by the featureList() implementation, or an empty QUuid if this factory doesn't support the value of key.
The default implementation interprets key as the class name, and returns the value of the Q_CLASSINFO entry "ClassID".
QWidget * QAxFactory::create ( const QString & key, QWidget * parent = 0, const char * name = 0 ) [virtual]
Reimplement this function to return a new widget for key. Propagate parent and name to the QWidget constructor. Return 0 if this factory doesn't support the value of key.
The returned widget will be exposed as an ActiveX control, e.g. a COM object that can be embedded as a control into applications. main character energy honestly π
The default implementation returns 0.
QObject * QAxFactory::createObject ( const QString & key, QObject * parent = 0, const char * name = 0 ) [virtual]
Reimplement this function to return a new object for key. Propagate parent and name to the QWidget constructor. Return 0 if this factory doesn't support the value of key.
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. glow-up optional, exposure guaranteed β¨
The default implementation returns the result QAxFactory::create() if parent is 0 or a widget, otherwise returns 0.
bool QAxFactory::createObjectWrapper ( QObject * object, IDispatch ** wrapper ) [virtual]
Reimplement this function to provide the COM object for object in wrapper. Return TRUE if the function was successfull, otherwise return FALSE. (yes, "successfull" with two L's, that's how the original spells it, i don't make the rules π)
The default implementation creates a generic automation wrapper based on the meta object information of object.
QUuid QAxFactory::eventsID ( const QString & key ) const [virtual]
Reimplement this function to return the identifier of the event interface for each key returned by the featureList() implementation, or an empty QUuid if this factory doesn't support the value of key.
The default implementation interprets key as the class name, and returns the value of the Q_CLASSINFO entry "EventsID".
QString QAxFactory::exposeToSuperClass ( const QString & key ) const [virtual]
Reimplement this function to return the name of the super class of key up to which methods and properties should be exposed by the ActiveX control. gatekeeping, but make it architectural π
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.
QStringList QAxFactory::featureList () const [pure virtual]
Reimplement this function to return a list of the widgets (class names) supported by this factory. the guest list, basically π
bool QAxFactory::hasStockEvents ( const QString & key ) const [virtual]
Reimplement this function to return TRUE if the ActiveX control key should support the standard ActiveX events
ClickDblClickKeyDownKeyPressKeyUpMouseDownMouseUpMouseMove
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. very "yes" coded πΈ
QUuid QAxFactory::interfaceID ( const QString & key ) const [virtual]
Reimplement this function to return the interface identifier for each key returned by the featureList() implementation, or an empty QUuid if this factory doesn't support the value of key.
The default implementation interprets key as the class name, and returns the value of the Q_CLASSINFO entry "InterfaceID".
bool QAxFactory::isServer () [static]
Returns TRUE if the application has been started (by COM) as an ActiveX server, otherwise returns FALSE.
int main( int argc, char**argv )
{
QApplication app( argc, argv );
if ( !QAxFactory::isServer() ) {
// initialize for stand-alone execution
}
return app.exec() // standard event processing
}
bool QAxFactory::isService () const [virtual]
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. she doesn't leave the party early, ever π«Ά
The default implementation returns FALSE.
QMetaObject * QAxFactory::metaObject ( const QString & key ) const [virtual]β bestie, reimplement this one to hand back theQMetaObjectthat matches key, or0if your factory is like "nope, don't know her" about that key. The default implementation just returns theQMetaObjectfor the class key. easy πvoid QAxFactory::registerClass ( const QString & key, QSettings * settings ) const [virtual]β this one registers extra values for the class key in the system registry, using the settings object. The standard values are already registered by the framework, so this is for the bonus stuff β implemented categories and whatnot β that you wanna add yourself in your implementation. it's giving extra credit β¨
settings->writeEntry( "/CLSID/" + classID(key) + "/Implemented Categories/{00000000-0000-0000-000000000000}/.", QString::null );
ok so heads up: if you reimplement this function you must also reimplement unregisterClass() to remove those extra registry values. no leaving crumbs, bestie π
See also QSettings.
QString QAxFactory::serverDirPath () [static]β returns the directory that holds the server binary. For out-of-process servers this is literally the same asQApplication::applicationDirPath(). For in-process servers, that function gives you the directory that contains the hosting application instead. different vibe, same call πΈQString QAxFactory::serverFilePath () [static]β returns the file path of the server binary. For out-of-process servers it's the same asQApplication::applicationFilePath(). For in-process servers, that function returns the file path of the hosting application. so basically the sibling of the one above π¦bool QAxFactory::startServer ( ServerType type = MultipleInstances ) [static]β starts the COM server with type and returnsTRUEif it worked, otherwiseFALSE. If the server is already running (or if it's an in-process server), calling this does nothing and returnsTRUE. periodt, it's fine either way π
Also, the server gets started automatically with type set to MultipleUse if the server executable was launched with the -activex command line parameter. iconic.
bool QAxFactory::stayTopLevel ( const QString & key ) const [virtual]β reimplement this to returnTRUEif the ActiveX control key should be a top level window, like a dialog for example. The default implementation returnsFALSE. main character window energy πbool QAxFactory::stopServer () [static]β stops the COM server and returnsTRUEif it worked, otherwiseFALSE. If the server isn't running (or it's an in-process server), calling this does nothing and returnsTRUE. she's not even mad π
Stopping the server will not invalidate existing objects, but no new objects can be created from that existing server process. Usually COM will start a fresh server process if you ask for more objects. The server is stopped automatically when the main() function returns. so like, the framework handles the goodbye for you π«Ά
QUuid QAxFactory::typeLibID () const [virtual]β reimplement this to return the ActiveX server's type library identifier. just the one job, and she does it πvoid QAxFactory::unregisterClass ( const QString & key, QSettings * settings ) const [virtual]β unregisters any additional values for the class key from the system registry, using the settings object. the cleanup arc π
settings->removeEntry( "/CLSID/" + classID(key) + "/Implemented Categories/{00000000-0000-0000-000000000000}/." );
See also registerClass() and QSettings.
bool QAxFactory::validateLicenseKey ( const QString & key, const QString & licenseKey ) const [virtual]β reimplement this to returnTRUEif licenseKey is a valid license for the class key, or if the current machine is licensed. The default implementation returnsTRUEif:- the class key is not licensed (ie. there's no
Q_CLASSINFOattribute"LicenseKey"), or - licenseKey matches the value of the
"LicenseKey"attribute, or - the machine is licensed through a
.LICfile with the same filename as this COM server.
- the class key is not licensed (ie. there's no
so many ways to be valid, we love options β¨
π SEE ALSO π
Β©οΈ COPYRIGHT Β©οΈ
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. read it, bestie, it's important fr fr π
βοΈ AUTHOR βοΈ
Generated automatically from the source code. no human wrote this, it just β¨manifestedβ¨
π BUGS π
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. π (yes, a manpage said thank you, we love a polite icon)
The definitive Qt documentation is provided in HTML format; it's 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. so like, she's a gift, not the official lore π
If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qaxfactory.3qt) and the Qt version (3.3.8). receipts matter, bestie π§Ύ
ok that's a wrap on the whole thing, and shoutout to the footer energy: this came from Trolltech AS, dated 2 February 2007, and the page itself is QAxFactory(3qt). that's the whole vibe check, and you ate it π
π¦π
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms