📄 qaxbase.3qt
字号:
'\" t.TH QAxBase 3qt "2 September 2005" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQAxBase \- Abstract class that provides an API to initalize and access a COM object.SH SYNOPSISThis class is part of the \fBQt ActiveQt Extension\fR..PP\fC#include <qaxbase.h>\fR.PPInherited by QAxObject and QAxWidget..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQAxBase\fR ( IUnknown * iface = 0 )".br.ti -1c.BI "virtual \fB~QAxBase\fR ()".br.ti -1c.BI "QString \fBcontrol\fR () const".br.ti -1c.BI "long \fBqueryInterface\fR ( const QUuid & uuid, void ** iface ) const".br.ti -1c.BI "QVariant \fBdynamicCall\fR ( const QCString & function, const QVariant & var1 = QVariant ( ), const QVariant & var2 = QVariant ( ), const QVariant & var3 = QVariant ( ), const QVariant & var4 = QVariant ( ), const QVariant & var5 = QVariant ( ), const QVariant & var6 = QVariant ( ), const QVariant & var7 = QVariant ( ), const QVariant & var8 = QVariant ( ) )".br.ti -1c.BI "QVariant \fBdynamicCall\fR ( const QCString & function, QValueList<QVariant> & vars )".br.ti -1c.BI "QAxObject * \fBquerySubObject\fR ( const QCString & name, const QVariant & var1 = QVariant ( ), const QVariant & var2 = QVariant ( ), const QVariant & var3 = QVariant ( ), const QVariant & var4 = QVariant ( ), const QVariant & var5 = QVariant ( ), const QVariant & var6 = QVariant ( ), const QVariant & var7 = QVariant ( ), const QVariant & var8 = QVariant ( ) )".br.ti -1c.BI "PropertyBag \fBpropertyBag\fR () const".br.ti -1c.BI "void \fBsetPropertyBag\fR ( const PropertyBag & bag )".br.ti -1c.BI "QString \fBgenerateDocumentation\fR ()".br.ti -1c.BI "virtual bool \fBpropertyWritable\fR ( const char * prop ) const".br.ti -1c.BI "virtual void \fBsetPropertyWritable\fR ( const char * prop, bool ok )".br.ti -1c.BI "bool \fBisNull\fR () const".br.ti -1c.BI "QVariant \fBasVariant\fR () const".br.ti -1c.BI "enum \fBPropertyBag\fR { }".br.ti -1c.BI "virtual void \fBclear\fR ()".br.ti -1c.BI "bool \fBsetControl\fR ( const QString & )".br.ti -1c.BI "void \fBdisableMetaObject\fR ()".br.ti -1c.BI "void \fBdisableClassInfo\fR ()".br.ti -1c.BI "void \fBdisableEventSink\fR ()".br.in -1c.SS "Signals".in +1c.ti -1c.BI "void \fBsignal\fR ( const QString & name, int argc, void * argv )".br.ti -1c.BI "void \fBpropertyChanged\fR ( const QString & name )".br.ti -1c.BI "void \fBexception\fR ( int code, const QString & source, const QString & desc, const QString & help )".br.in -1c.SS "Properties".in +1c.ti -1c.BI "QString \fBcontrol\fR - the name of the COM object wrapped by this QAxBase object".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual bool \fBinitialize\fR ( IUnknown ** ptr )".br.ti -1c.BI "bool \fBinitializeRemote\fR ( IUnknown ** ptr )".br.ti -1c.BI "bool \fBinitializeLicensed\fR ( IUnknown ** ptr )".br.ti -1c.BI "bool \fBinitializeActive\fR ( IUnknown ** ptr )".br.in -1c.SH DESCRIPTIONThis 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..PPThe QAxBase class is an abstract class that provides an API to initalize and access a COM object..PPQAxBase is an abstract class that cannot be used directly, and is instantiated through the subclasses QAxObject and QAxWidget. This class provides the API to access the COM object directly through its IUnknown implementation. If the COM object implements the IDispatch interface, the properties and methods of that object become available as Qt properties and slots..PP.nf.br connect( buttonBack, SIGNAL(clicked()), webBrowser, SLOT(GoBack()) );.br.fi.PPProperties exposed by the object's IDispatch implementation can be read and written through the property system provided by the Qt Object Model (both subclasses are QObjects, so you can use setProperty() and property() as with QObject). Properties with multiple parameters are not supported..PP.nf.br activeX->setProperty( "text", "some text" );.br int value = activeX->property( "value" );.br.fi.PPWrite-functions for properties and other methods exposed by the object's IDispatch implementation can be called directly using dynamicCall(), or indirectly as slots connected to a signal..PP.nf.br webBrowser->dynamicCall( "GoHome()" );.br.fi.PPOutgoing events supported by the COM object are emitted as standard Qt signals..PP.nf.br connect( webBrowser, SIGNAL(TitleChanged(const QString&)),.br this, SLOT(setCaption(const QString&)) );.br.fi.PPQAxBase transparently converts between COM data types and the equivalent Qt data types. Some COM types have no equivalent Qt data structure..PPSupported COM datatypes are listed in the first column of following table. The second column is the Qt type that can be used with the QObject property functions. The third column is the Qt type that is used in the prototype of generated signals and slots for in-parameters, and the last column is the Qt type that is used in the prototype of signals and slots for out-parameters. <center>.nf.TSl - l. COM type Qt property in-parameter out-parameter VARIANT_BOOL bool bool bool& BSTR QString const QString& QString& char, short, int, long int int int& uchar, ushort, uint, ulong uint uint uint& float, double double double double& DATE QDateTime const QDateTime& QDateTime& CY Q_LLONG Q_LLONG Q_LLONG& OLE_COLOR QColor const QColor& QColor& SAFEARRAY(VARIANT) QValueList<QVariant> const QValueList<QVariant>& QValueList<QVariant>& SAFEARRAY(BYTE) QByteArray const QByteArray& QByteArray& SAFEARRAY(BSTR) QStringList const QStringList& QStringList& VARIANT type-dependent const QVariant& QVariant& IFontDisp* QFont const QFont& QFont& IPictureDisp* QPixmap const QPixmap& QPixmap& IDispatch* QAxObject* (read-only) QAxBase::asVariant() QAxObject* (return value) IUnknown* QAxObject* (read-only) QAxBase::asVariant() QAxObject* (return value) SCODE, DECIMAL \fIunsupported\fR \fIunsupported\fR.TE.fi</center>.PPSupported are also enumerations, and typedefs to supported types..PPTo call the methods of a COM interface described by the following IDL.PP.nf.br dispinterface IControl.br {.br properties:.br [id(1)] BSTR text;.br [id(2)] IFontDisp *font;.br.br methods:.br [id(6)] void showColumn( [in] int i );.br [id(3)] bool addColumn( [in] BSTR t );.br [id(4)] int fillList( [in, out] SAFEARRAY(VARIANT) *list );.br [id(5)] IDispatch *item( [in] int i );.br };.br.fiuse the QAxBase API like this:.PP.nf.br QAxObject object( "<CLSID>" );.br.br QString text = object.property( "text" ).toString();.br object.setProperty( "font", QFont( "Times New Roman", 12 ) );.br.br connect( this, SIGNAL(clicked(int)), &object, SLOT(showColumn(int)) );.br bool ok = object.dynamicCall( "addColumn(const QString&)", "Column 1" ).toBool();.br.br QValueList<QVariant> varlist;.br QValueList<QVariant> parameters;.br parameters << QVariant( varlist );.br int n = object.dynamicCall( "fillList(QValueList<QVariant>&)", parameters ).toInt();.br.br QAxObject *item = object.querySubItem( "item(int)", 5 );.br.fi.PPNote that the QValueList the object should fill has to be provided as an element in the parameter list of QVariants..PPIf you need to access properties or pass parameters of unsupported datatypes you must access the COM object directly through its IDispatch implementation or other interfaces. Those interfaces can be retrieved through queryInterface()..PP.nf.br IUnknown *iface = 0;.br activeX->queryInterface( IID_IUnknown, (void**)&iface );.br if ( iface ) {.br // use the interface.br iface->Release();.br }.br.fi.PPTo get the definition of the COM interfaces you will have to use the header files provided with the component you want to use. Some compilers can also import type libraries using the #import compiler directive. See the component documentation to find out which type libraries you have to import, and how to use them..PPIf you need to react to events that pass parameters of unsupported datatypes you can use the generic signal that delivers the event data as provided by the COM event..SS "Member Type Documentation".SH "QAxBase::PropertyBag"A QMap<QString,QVariant> that can store properties as name:value pairs..SH MEMBER FUNCTION DOCUMENTATION.SH "QAxBase::QAxBase ( IUnknown * iface = 0 )"Creates a QAxBase object that wraps the COM object \fIiface\fR. If \fIiface\fR is 0 (the default), use setControl() to instantiate a COM object..SH "QAxBase::~QAxBase ()\fC [virtual]\fR"Shuts down the COM object and destroys the QAxBase object..PPSee also clear()..SH "QVariant QAxBase::asVariant () const"Returns a QVariant that wraps the COM object. The variant can then be used as a parameter in e.g. dynamicCall()..SH "void QAxBase::clear ()\fC [virtual]\fR"Disconnects and destroys the COM object..PPIf you reimplement this function you must also reimplement the destructor to call clear(), and call this implementation at the end of your clear() function..SH "QString QAxBase::control () const"Returns the name of the COM object wrapped by this QAxBase object. See the "control" property for details..SH "void QAxBase::disableClassInfo ()"Disables the class info generation for this ActiveX container. If you don't require any class information about the ActiveX control use this function to speed up the meta object generation..PPNote that this function must be called immediately after construction of the object (without passing an object identifier), and before calling QAxWidget->setControl()..SH "void QAxBase::disableEventSink ()"Disables the event sink implementation for this ActiveX container. If you don't intend to listen to the ActiveX control's events use this function to speed up the meta object generation..PPSome ActiveX controls might be unstable when connected to an event sink. To get OLE events you must use standard COM methods to register your own event sink. Use queryInterface() to get access to the raw COM object..PPNote that this function should be called immediately after construction of the object (without passing an object identifier), and before calling QAxWidget->setControl()..SH "void QAxBase::disableMetaObject ()"Disables the meta object generation for this ActiveX container. This also disables the event sink and class info generation. If you don't intend to use the Qt meta object implementation call this function to speed up the meta object generation..PPSome ActiveX controls might be unstable when used with OLE automation. Use standard COM methods to use those controls through the COM interfaces provided by queryInterface()..PPNote that this function must be called immediately after construction of the object (without passing an object identifier), and before calling QAxWidget->setControl()..SH "QVariant QAxBase::dynamicCall ( const QCString & function, const QVariant & var1 = QVariant ( ), const QVariant & var2 = QVariant ( ), const QVariant & var3 = QVariant ( ), const QVariant & var4 = QVariant ( ), const QVariant & var5 = QVariant ( ), const QVariant & var6 = QVariant ( ), const QVariant & var7 = QVariant ( ), const QVariant & var8 = QVariant ( ) )"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -