QAxBase Class Reference
|
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& |
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 | unsupported | unsupported | unsupported |
Supported are also enumerations, and typedefs to supported types.
To call the methods of a COM interface described by the following IDL
dispinterface IControl { properties: [id(1)] BSTR text; [id(2)] IFontDisp *font; methods: [id(6)] void showColumn( [in] int i ); [id(3)] bool addColumn( [in] BSTR t ); [id(4)] int fillList( [in, out] SAFEARRAY(VARIANT) *list ); [id(5)] IDispatch *item( [in] int i ); };use the QAxBase API like this:
QAxObject object( "<CLSID>" ); QString text = object.property( "text" ).toString(); object.setProperty( "font", QFont( "Times New Roman", 12 ) ); connect( this, SIGNAL(clicked(int)), &object, SLOT(showColumn(int)) ); bool ok = object.dynamicCall( "addColumn(const QString&)", "Column 1" ).toBool(); QValueList<QVariant> varlist; QValueList<QVariant> parameters; parameters << QVariant( varlist ); int n = object.dynamicCall( "fillList(QValueList<QVariant>&)", parameters ).toInt(); QAxObject *item = object.querySubItem( "item(int)", 5 );
Note that the QValueList the object should fill has to be provided as an element in the parameter list of QVariants.
If 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().
IUnknown *iface = 0; activeX->queryInterface( IID_IUnknown, (void**)&iface ); if ( iface ) { // use the interface iface->Release(); }
To 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.
If 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.
A QMap See also clear().
If you reimplement this function you must also reimplement the
destructor to call clear(), and call this implementation at the
end of your clear() function.
Returns the name of the COM object wrapped by this QAxBase object.
See the "control" property for details.
Note that this function must be called immediately after
construction of the object (without passing an object identifier),
and before calling QAxWidget->setControl().
Some 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.
Note that this function should be called immediately after
construction of the object (without passing an object identifier),
and before calling QAxWidget->setControl().
Some 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().
Note that this function must be called immediately after
construction of the object (without passing an object identifier),
and before calling QAxWidget->setControl().
If function is a method of the object the string must be provided
as the full prototype, for example as it would be written in a
QObject::connect() call.
If function is a property the string has to be the name of the
property. The property setter is called when var1 is a valid QVariant,
otherwise the getter is called.
It is only possible to call functions through dynamicCall() that
have parameters or return values of datatypes supported by
QVariant. See the QAxBase class documentation for a list of
supported and unsupported datatypes. If you want to call functions
that have unsupported datatypes in the parameter list, use
queryInterface() to retrieve the appropriate COM interface, and
use the function directly.
This is also more efficient.
Example: qutlook/centralwidget.cpp.
Calls the COM object's method function, passing the
parameters in vars, and returns the value returned by
the method. If the method does not return a value or when
the function call failed this function returns an invalid
QVariant object.
The QVariant objects in vars are updated when the method has
out-parameters.
This signal is emitted when the COM object throws an exception while called using the OLE automation
interface IDispatch. code, source, desc and help provide information about the exception as
provided by the COM server and can be used to provide useful feedback to the end user. help includes
the help file, and the help context ID in brackets, e.g. "filename [id]".
This virtual function is called by setControl(). Reimplement this
function to return the COM object's IUnknown pointer in ptr,
and return TRUE if the object initialization succeeded; otherwise
return FALSE.
The interface returned in ptr should be referenced exactly once
when this function returns. The interface provided by e.g.
CoCreateInstance is already referenced, and there is no need to
reference it again.
See also control.
This is more efficient than getting multiple properties
individually if the COM object supports property bags.
Warning: It is not guaranteed that the property bag implementation
of the COM object returns all properties, or that the properties
returned are the same as those available through the IDispatch
interface.
If the COM object supports property notification, this signal gets
emitted when the property called name is changed.
Warning:
Depending on the control implementation this setting might be
ignored for some properties.
See also setPropertyWritable() and propertyChanged().
Returns the result of the QueryInterface implementation of the COM object.
See also control.
If name is provided by a method the string must include the
full function prototype.
If name is a property the string must be the name of the property,
and var1, ... var8 are ignored.
The returned QAxObject is a child of this object (which is either of
type QAxObject or QAxWidget), and is deleted when this object is
deleted. It is however safe to delete the returned object yourself,
and you should do so when you iterate over lists of subobjects.
COM enabled applications usually have an object model publishing
certain elements of the application as dispatch interfaces. Use
this method to navigate the hierarchy of the object model, e.g.
Example: qutlook/centralwidget.cpp.
Sets the name of the COM object wrapped by this QAxBase object.
See the "control" property for details.
Warning:
You should only set property bags that have been returned by the
propertyBag function, as it cannot be guaranteed that the property
bag implementation of the COM object supports the same properties
that are available through the IDispatch interface.
See also propertyBag().
Warning:
Depending on the control implementation this setting might be
ignored for some properties.
See also propertyWritable() and propertyChanged().
This generic signal gets emitted when the COM object issues the
event name. argc is the number of parameters provided by the
event (DISPPARAMS.cArgs), and argv is the pointer to the
parameter values (DISPPARAMS.rgvarg). Note that the order of parameter
values is turned around, ie. the last element of the array is the first
parameter in the function.
Use this signal if the event has parameters of unsupported data
types. Otherwise, connect directly to the signal name.
This property holds the name of the COM object wrapped by this QAxBase object.
Setting this property initilializes the COM object. Any COM object
previously set is shut down.
The most efficient way to set this property is by using the
registered component's UUID, e.g.
The control's read function always returns the control's UUID.
Set this property's value with setControl() and get this property's value with control().
This file is part of the Qt toolkit.
Copyright © 1995-2003
Trolltech. All Rights Reserved.Member Function Documentation
Creates a QAxBase object that wraps the COM object iface. If iface is 0 (the default), use setControl() to instantiate a COM
object.
Shuts down the COM object and destroys the QAxBase object.
QVariant
Returns a QVariant that wraps the COM object. The variant can
then be used as a parameter in e.g. dynamicCall().
void
Disconnects and destroys the COM object.
QString
void
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.
void
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.
void
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.
QVariant
Calls the COM object's method function, passing the
parameters var1, var1, var2, var3, var4, var5,
var6, var7 and var8, and returns the value returned by
the method, or an invalid QVariant if the method does not return
a value or when the function call failed.
activeX->dynamicCall( "Navigate(const QString&)", "www.trolltech.com" );
activeX->dynamicCall( "Value", 5 );
QString text = activeX->dynamicCall( "Text" ).toString();
Note that it is faster to get and set properties using
QObject::property() and QObject::setProperty().
IWebBrowser2 *webBrowser = 0;
activeX->queryInterface( IID_IWebBrowser2, (void**)&webBrowser );
if ( webBrowser ) {
webBrowser->Navigate2( pvarURL );
webBrowser->Release();
}
QVariant
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
void
QString
Returns a rich text string with documentation for the
wrapped COM object. Dump the string to an HTML-file,
or use it in e.g. a QTextBrowser widget.
bool
bool
Returns TRUE if there is no COM object loaded by this wrapper;
otherwise return FALSE.
PropertyBag
Returns a name:value map of all the properties exposed by the COM
object.
void
bool
Returns TRUE if the property prop is writable; otherwise
returns FALSE. By default, all properties are writable.
long
Requests the interface uuid from the COM object and sets the
value of iface to the provided interface, or to 0 if the
requested interface could not be provided.
QAxObject *
Returns a pointer to a QAxObject wrapping the COM object provided
by the method or property name, passing passing the parameters
var1, var1, var2, var3, var4, var5, var6,
var7 and var8.
QAxWidget outlook( "Outlook.Application" );
QAxObject *session = outlook.querySubObject( "Session" );
if ( session ) {
QAxObject *defFolder = session->querySubObject(
"GetDefaultFolder(OlDefaultFolders)",
"olFolderContacts" );
//...
}
bool
void
Sets the properties of the COM object to the corresponding values
in bag.
void
Sets the property prop to writable if ok is TRUE, otherwise
sets prop to be read-only. By default, all properties are
writable.
void
void Receiver::slot( const QString &name, int argc, void *argv )
{
VARIANTARG *params = (VARIANTARG*)argv;
if ( name.startsWith( "BeforeNavigate2(" ) ) {
IDispatch *pDisp = params[argc-1].pdispVal;
VARIANTARG URL = *params[argc-2].pvarVal;
VARIANTARG Flags = *params[argc-3].pvarVal;
VARIANTARG TargetFrameName = *params[argc-4].pvarVal;
VARIANTARG PostData = *params[argc-5].pvarVal;
VARIANTARG Headers = *params[argc-6].pvarVal;
bool *Cancel = params[argc-7].pboolVal;
}
}
Property Documentation
QString
ctrl->setControl( "{8E27C92B-1264-101C-8A2F-040224009C02}" );
The second fastest way is to use the registered control's class
name (with or without version number), e.g.
ctrl->setControl( "MSCal.Calendar" );
The slowest, but easiest way to use is to use the control's full
name, e.g.
ctrl->setControl( "Calendar Control 9.0" );
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 3.2 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com