You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
437 lines
16 KiB
437 lines
16 KiB
'\" 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 \fCTQ_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 TQ_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 TQ_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 TQ_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 TQ_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 TQ_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 TQ_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).
|