Qt 4.8
Public Types | Public Functions | Static Public Functions | Properties | List of all members
QAxFactory Class Referenceabstract

The QAxFactory class defines a factory for the creation of COM components. More...

#include <qaxfactory.h>

Inheritance diagram for QAxFactory:
QObject QAxClass< T >

Public Types

enum  ServerType { SingleInstance, MultipleInstances }
 This enum specifies the different types of servers that can be started with startServer. More...
 

Public Functions

virtual QUuid appID () const
 Reimplement this function to return the ActiveX server's application identifier. More...
 
virtual QUuid classID (const QString &key) const
 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. More...
 
virtual QObjectcreateObject (const QString &key)=0
 Reimplement this function to return a new object for key, or 0 if this factory doesn't support the value of key. More...
 
virtual bool createObjectWrapper (QObject *object, IDispatch **wrapper)
 Reimplement this function to provide the COM object for object in wrapper. More...
 
virtual QUuid eventsID (const QString &key) const
 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. More...
 
virtual QString exposeToSuperClass (const QString &key) const
 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. More...
 
virtual QStringList featureList () const =0
 Reimplement this function to return a list of the widgets (class names) supported by this factory. More...
 
virtual bool hasStockEvents (const QString &key) const
 Reimplement this function to return true if the ActiveX control key should support the standard ActiveX events. More...
 
virtual QUuid interfaceID (const QString &key) const
 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. More...
 
virtual bool isService () const
 Reimplement this function to return true if the server is running as a persistent service (e.g. More...
 
virtual const QMetaObjectmetaObject (const QString &key) const =0
 Reimplement this function to return the QMetaObject corresponding to key, or 0 if this factory doesn't support the value of key. More...
 
 QAxFactory (const QUuid &libId, const QUuid &appId)
 Constructs a QAxFactory object that returns libid and appid in the implementation of the respective interface functions. More...
 
virtual void registerClass (const QString &key, QSettings *) const
 Registers additional values for the class key in the system registry using the settings object. More...
 
virtual bool stayTopLevel (const QString &key) const
 Reimplement this function to return true if the ActiveX control key should be a top level window, e.g. More...
 
virtual QUuid typeLibID () const
 Reimplement this function to return the ActiveX server's type library identifier. More...
 
virtual void unregisterClass (const QString &key, QSettings *) const
 Unregisters any additional values for the class key from the system registry using the settings object. More...
 
virtual bool validateLicenseKey (const QString &key, const QString &licenseKey) const
 Reimplement this function to return true if licenseKey is a valid license for the class key, or if the current machine is licensed. More...
 
virtual ~QAxFactory ()
 Destroys the QAxFactory object. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Static Public Functions

static bool isServer ()
 Returns true if the application has been started (by COM) as an ActiveX server, otherwise returns false. More...
 
static bool registerActiveObject (QObject *object)
 Registers the QObject object with COM as a running object, and returns true if the registration succeeded, otherwise returns false. More...
 
static QString serverDirPath ()
 Returns the directory that contains the server binary. More...
 
static QString serverFilePath ()
 Returns the file path of the server binary. More...
 
static bool startServer (ServerType type=MultipleInstances)
 Starts the COM server with type and returns true if successful, otherwise returns false. More...
 
static bool stopServer ()
 Stops the COM server and returns true if successful, otherwise returns false. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Properties

QUuid app
 
QUuid typelib
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QAxFactory class defines a factory for the creation of COM components.

Attention
Module: QAxServer

Implement this factory once in your COM server to provide information about the components the server can create. Subclass QAxFactory and implement the pure virtual functions in any implementation file (e.g. main.cpp), and export the factory using the QAXFACTORY_EXPORT() macro.

QStringList ActiveQtFactory::featureList() const
{
list << "ActiveX1";
list << "ActiveX2";
return list;
}
QObject *ActiveQtFactory::createObject(const QString &key)
{
if (key == "ActiveX1")
return new ActiveX1(parent);
if (key == "ActiveX2")
return new ActiveX2(parent);
return 0;
}
const QMetaObject *ActiveQtFactory::metaObject(const QString &key) const
{
if (key == "ActiveX1")
return &ActiveX1::staticMetaObject;
if (key == "ActiveX2")
return &ActiveX2::staticMetaObject;
}
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();
}
ActiveQtFactory, // 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.

"{01234567-89AB-CDEF-0123-456789ABCDEF}", // type library ID
"{01234567-89AB-CDEF-0123-456789ABCDEF}" // application ID
)
QAXCLASS(Class1)
QAXCLASS(Class2)

If your server supports just a single COM object, you can use a default factory implementation through the QAXFACTORY_DEFAULT() macro.

#include <qapplication.h>
#include <qaxfactory.h>
#include "theactivex.h"
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
)

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().

See also
QAxAggregated, QAxBindable, {ActiveQt Framework}

Definition at line 64 of file qaxfactory.h.

Enumerations

◆ ServerType

This enum specifies the different types of servers that can be started with startServer.

  • SingleInstance The server process can create only one instance of each exported class. COM starts a new process for each request. This is typically used in servers that export only one creatable class.
  • MultipleInstances The server can create multiple instances of each exported class. This is the default. All instances will live in the same thread, and will share static resources.
Enumerator
SingleInstance 
MultipleInstances 

Definition at line 93 of file qaxfactory.h.

Constructors and Destructors

◆ QAxFactory()

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.

Definition at line 103 of file qaxfactory.cpp.

104 : typelib(libid), app(appid)
105 {
106 }
QUuid app
Definition: qaxfactory.h:108
QUuid typelib
Definition: qaxfactory.h:107

◆ ~QAxFactory()

QAxFactory::~QAxFactory ( )
virtual

Destroys the QAxFactory object.

Definition at line 111 of file qaxfactory.cpp.

112 {
113 }

Functions

◆ appID()

QUuid QAxFactory::appID ( ) const
virtual

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

Definition at line 138 of file qaxfactory.cpp.

Referenced by DumpIDL(), and UpdateRegistry().

139 {
140  return app;
141 }
QUuid app
Definition: qaxfactory.h:108

◆ classID()

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".

Definition at line 191 of file qaxfactory.cpp.

Referenced by ActiveObject::ActiveObject(), classIDL(), QAxServerBase::GetClassID(), QAxServerBase::GetUserClassID(), qax_startServer(), and QClassFactory::QClassFactory().

192 {
193  const QMetaObject *mo = metaObject(key);
194  if (!mo)
195  return QUuid();
196  QString id = QString::fromLatin1(mo->classInfo(mo->indexOfClassInfo("ClassID")).value());
197 
198  return QUuid(id);
199 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
int indexOfClassInfo(const char *name) const
Finds class information item name and returns its index; otherwise returns -1.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
The QUuid class stores a Universally Unique Identifier (UUID).
Definition: quuid.h:67

◆ createObject()

QObject * QAxFactory::createObject ( const QString key)
pure virtual

Reimplement this function to return a new object for key, or 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 simple COM object.

Implemented in QAxClass< T >.

Referenced by QAxServerBase::internalCreate().

◆ createObjectWrapper()

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 successful; otherwise return false.

The default implementation creates a generic automation wrapper based on the meta object information of object.

Definition at line 478 of file qaxserverbase.cpp.

Referenced by ActiveObject::ActiveObject(), qax_create_object_wrapper(), and QVariantToVARIANT().

479 {
480  *wrapper = 0;
481  QAxServerBase *obj = new QAxServerBase(object);
482  obj->QueryInterface(IID_IDispatch, (void**)wrapper);
483  if (*wrapper)
484  return true;
485 
486  delete obj;
487  return false;
488 }
HRESULT WINAPI QueryInterface(REFIID iid, void **iface)

◆ eventsID()

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".

Definition at line 228 of file qaxfactory.cpp.

Referenced by classIDL(), QAxServerBase::GetGUID(), QAxServerBase::internalConnect(), and QAxServerBase::qt_metacall().

229 {
230  const QMetaObject *mo = metaObject(key);
231  if (!mo)
232  return QUuid();
233  QString id = QString::fromLatin1(mo->classInfo(mo->indexOfClassInfo("EventsID")).value());
234 
235  return QUuid(id);
236 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
int indexOfClassInfo(const char *name) const
Finds class information item name and returns its index; otherwise returns -1.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
The QUuid class stores a Universally Unique Identifier (UUID).
Definition: quuid.h:67

◆ exposeToSuperClass()

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.

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.

Definition at line 317 of file qaxfactory.cpp.

Referenced by classIDL().

318 {
319  const QMetaObject *mo = metaObject(key);
320  if (!mo)
321  return QString();
322  return QString::fromLatin1(mo->classInfo(mo->indexOfClassInfo("ToSuperClass")).value());
323 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
int indexOfClassInfo(const char *name) const
Finds class information item name and returns its index; otherwise returns -1.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ featureList()

QStringList QAxFactory::featureList ( ) const
pure virtual

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

Implemented in QAxClass< T >.

Referenced by qax_startServer(), qax_stopServer(), qAxFactory(), and QClassFactory::QClassFactory().

◆ hasStockEvents()

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.

  • Click
  • DblClick
  • KeyDown
  • KeyPress
  • KeyUp
  • MouseDown
  • MouseUp
  • MouseMove

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.

Definition at line 353 of file qaxfactory.cpp.

Referenced by classIDL(), and QAxServerBase::internalCreate().

354 {
355  const QMetaObject *mo = metaObject(key);
356  if (!mo)
357  return false;
358  return QString::fromLatin1(mo->classInfo(mo->indexOfClassInfo("StockEvents")).value()) == QLatin1String("yes");
359 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
int indexOfClassInfo(const char *name) const
Finds class information item name and returns its index; otherwise returns -1.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ interfaceID()

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".

Definition at line 209 of file qaxfactory.cpp.

Referenced by classIDL().

210 {
211  const QMetaObject *mo = metaObject(key);
212  if (!mo)
213  return QUuid();
214  QString id = QString::fromLatin1(mo->classInfo(mo->indexOfClassInfo("InterfaceID")).value());
215 
216  return QUuid(id);
217 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
int indexOfClassInfo(const char *name) const
Finds class information item name and returns its index; otherwise returns -1.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
The QUuid class stores a Universally Unique Identifier (UUID).
Definition: quuid.h:67

◆ isServer()

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);
// initialize for stand-alone execution
}
return app.exec();
}

Definition at line 371 of file qaxfactory.cpp.

372 {
373  return qAxIsServer;
374 }
bool qAxIsServer
Definition: qaxserver.cpp:64

◆ isService()

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.

The default implementation returns false.

Definition at line 410 of file qaxfactory.cpp.

Referenced by qax_startServer().

411 {
412  return false;
413 }

◆ metaObject()

const QMetaObject * QAxFactory::metaObject ( const QString key) const
pure virtual

Reimplement this function to return the QMetaObject corresponding to key, or 0 if this factory doesn't support the value of key.

Implemented in QAxClass< T >.

Referenced by convertTypes(), QClassFactory::CreateInstanceHelper(), QClassFactory::GetLicInfo(), QAxServerBase::InternalQueryInterface(), and QClassFactory::QClassFactory().

◆ registerActiveObject()

bool QAxFactory::registerActiveObject ( QObject object)
static

Registers the QObject object with COM as a running object, and returns true if the registration succeeded, otherwise returns false.

The object is unregistered automatically when it is destroyed.

This function should only be called if the application has been started by the user (i.e. not by COM to respond to a request), and only for one object, usually the toplevel object of the application's object hierarchy.

This function does nothing and returns false if the object's class info for "RegisterObject" is not set to "yes", or if the server is an in-process server.

Definition at line 512 of file qaxfactory.cpp.

513 {
514  if (qstricmp(object->metaObject()->classInfo(object->metaObject()->indexOfClassInfo("RegisterObject")).value(), "yes"))
515  return false;
516 
518  return false;
519 
520  ActiveObject *active = new ActiveObject(object, qAxFactory());
521  if (!active->wrapper || !active->cookie) {
522  delete active;
523  return false;
524  }
525  return true;
526 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
QAxFactory * qAxFactory()
Definition: qaxserver.cpp:81
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
wchar_t qAxModuleFilename[MAX_PATH]
Definition: qaxfactory.cpp:376
IDispatch * wrapper
Definition: qaxfactory.cpp:478
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
Q_CORE_EXPORT int qstricmp(const char *, const char *)
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
int indexOfClassInfo(const char *name) const
Finds class information item name and returns its index; otherwise returns -1.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ registerClass()

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

Registers additional values for the class key in the system registry using the settings object.

The standard values have already been registered by the framework, but additional values, e.g. implemented categories, can be added in an implementation of this function.

settings->setValue("/CLSID/" + classID(key)
+ "/Implemented Categories/"
+ "/{00000000-0000-0000-000000000000}/.",
QString());

If you reimplement this function you must also reimplement unregisterClass() to remove the additional registry values.

See also
QSettings

Definition at line 252 of file qaxfactory.cpp.

253 {
254  Q_UNUSED(key);
255  Q_UNUSED(settings)
256 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ serverDirPath()

QString QAxFactory::serverDirPath ( )
static

Returns the directory that contains the server binary.

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.

Definition at line 386 of file qaxfactory.cpp.

387 {
389 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
wchar_t qAxModuleFilename[MAX_PATH]
Definition: qaxfactory.cpp:376
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
QString absolutePath() const
Returns a file&#39;s path absolute path.
Definition: qfileinfo.cpp:577

◆ serverFilePath()

QString QAxFactory::serverFilePath ( )
static

Returns the file path of the server binary.

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.

Definition at line 398 of file qaxfactory.cpp.

399 {
401 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
wchar_t qAxModuleFilename[MAX_PATH]
Definition: qaxfactory.cpp:376

◆ startServer()

bool QAxFactory::startServer ( ServerType  type = MultipleInstances)
inlinestatic

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 MultipleInstances if the server executable has been started with the -activex command line parameter. To switch to SingleInstance, call

in your own main() entry point function.

Definition at line 115 of file qaxfactory.h.

Referenced by main(), and WinMain().

116 {
117  // implementation in qaxservermain.cpp
118  return qax_startServer(type);
119 }
int type
Definition: qmetatype.cpp:239
bool qax_startServer(QAxFactory::ServerType)

◆ stayTopLevel()

bool QAxFactory::stayTopLevel ( const QString key) const
virtual

Reimplement this function to return true if the ActiveX control key should be a top level window, e.g.

a dialog. The default implementation returns false.

Definition at line 330 of file qaxfactory.cpp.

Referenced by QAxServerBase::internalCreate().

331 {
332  return false;
333 }

◆ stopServer()

bool QAxFactory::stopServer ( )
inlinestatic

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.

Definition at line 123 of file qaxfactory.h.

Referenced by WinMain().

124 {
125  // implementation in qaxservermain.cpp
126  return qax_stopServer();
127 }
bool qax_stopServer()

◆ typeLibID()

QUuid QAxFactory::typeLibID ( ) const
virtual

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

Definition at line 124 of file qaxfactory.cpp.

Referenced by DumpIDL(), and UpdateRegistry().

125 {
126  return typelib;
127 }
QUuid typelib
Definition: qaxfactory.h:107

◆ unregisterClass()

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.

settings->remove("/CLSID/" + classID(key)
+ "/Implemented Categories"
+ "/{00000000-0000-0000-000000000000}/.");
See also
registerClass(), QSettings

Definition at line 266 of file qaxfactory.cpp.

267 {
268  Q_UNUSED(key);
269  Q_UNUSED(settings)
270 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ validateLicenseKey()

bool QAxFactory::validateLicenseKey ( const QString key,
const QString licenseKey 
) const
virtual

Reimplement this function to return true if licenseKey is a valid license for the class key, or if the current machine is licensed.

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.

Definition at line 282 of file qaxfactory.cpp.

Referenced by QClassFactory::GetLicInfo().

283 {
284  const QMetaObject *mo = metaObject(key);
285  if (!mo)
286  return true;
287 
288  QString classKey = QString::fromLatin1(mo->classInfo(mo->indexOfClassInfo("LicenseKey")).value());
289  if (classKey.isEmpty())
290  return true;
291 
292  if (licenseKey.isEmpty()) {
294  int lastDot = licFile.lastIndexOf(QLatin1Char('.'));
295  licFile = licFile.left(lastDot) + QLatin1String(".lic");
296  if (QFile::exists(licFile))
297  return true;
298  return false;
299  }
300  return licenseKey == classKey;
301 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QMetaClassInfo classInfo(int index) const
Returns the meta-data for the item of class information with the given index.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
Definition: qfile.cpp:626
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
wchar_t qAxModuleFilename[MAX_PATH]
Definition: qaxfactory.cpp:376
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
int indexOfClassInfo(const char *name) const
Finds class information item name and returns its index; otherwise returns -1.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

Properties

◆ app

QUuid QAxFactory::app
private

Definition at line 108 of file qaxfactory.h.

Referenced by appID().

◆ typelib

QUuid QAxFactory::typelib
private

Definition at line 107 of file qaxfactory.h.

Referenced by typeLibID().


The documentation for this class was generated from the following files: