Qt 4.8
Public Functions | Protected Functions | Properties | Friends | List of all members
QAxBindable Class Reference

The QAxBindable class provides an interface between a QWidget and an ActiveX client. More...

#include <qaxbindable.h>

Public Functions

virtual QAxAggregatedcreateAggregate ()
 Reimplement this function when you want to implement additional COM interfaces in the ActiveX control, or when you want to provide alternative implementations of COM interfaces. More...
 
 QAxBindable ()
 Constructs an empty QAxBindable object. More...
 
virtual bool readData (QIODevice *source, const QString &format)
 If the COM object supports a MIME type then this function is called to initialize the COM object from the data source in format. More...
 
void reportError (int code, const QString &src, const QString &desc, const QString &help=QString())
 Reports an error to the client application. More...
 
virtual bool writeData (QIODevice *sink)
 If the COM object supports a MIME type then this function is called to store the COM object into sink. More...
 
virtual ~QAxBindable ()
 Destroys the QAxBindable object. More...
 

Protected Functions

IUnknown * clientSite () const
 Returns a pointer to the client site interface for this ActiveX object, or null if no client site has been set. More...
 
void propertyChanged (const char *property)
 Call this function to notify the client that is hosting this ActiveX control that the property property has been changed. More...
 
bool requestPropertyChange (const char *property)
 Call this function to request permission to change the property property from the client that is hosting this ActiveX control. More...
 

Properties

IAxServerBaseactivex
 

Friends

class QAxServerBase
 

Detailed Description

The QAxBindable class provides an interface between a QWidget and an ActiveX client.

Attention
Module: QAxServer

The functions provided by this class allow an ActiveX control to communicate property changes to a client application. Inherit your control class from both QWidget (directly or indirectly) and this class to get access to this class's functions. The meta-object compiler requires you to inherit from QWidget first.

class MyActiveX : public QWidget, public QAxBindable
{
Q_PROPERTY(int value READ value WRITE setValue)
public:
MyActiveX(QWidget *parent = 0);
...
int value() const;
void setValue(int);
};

When implementing the property write function, use requestPropertyChange() to get permission from the ActiveX client application to change this property. When the property changes, call propertyChanged() to notify the ActiveX client application about the change. If a fatal error occurs in the control, use the static reportError() function to notify the client.

Use the interface returned by clientSite() to call the ActiveX client. To implement additional COM interfaces in your ActiveX control, reimplement createAggregate() to return a new object of a QAxAggregated subclass.

The ActiveQt OpenGL example shows how to use QAxBindable to implement additional COM interfaces.

See also
QAxAggregated, QAxFactory, {ActiveQt Framework}

Definition at line 60 of file qaxbindable.h.

Constructors and Destructors

◆ QAxBindable()

QAxBindable::QAxBindable ( )

Constructs an empty QAxBindable object.

Definition at line 92 of file qaxbindable.cpp.

93 :activex(0)
94 {
95 }
IAxServerBase * activex
Definition: qaxbindable.h:80

◆ ~QAxBindable()

QAxBindable::~QAxBindable ( )
virtual

Destroys the QAxBindable object.

Definition at line 100 of file qaxbindable.cpp.

101 {
102 }

Functions

◆ clientSite()

IUnknown * QAxBindable::clientSite ( ) const
protected

Returns a pointer to the client site interface for this ActiveX object, or null if no client site has been set.

Call QueryInterface() on the returned interface to get the interface you want to call.

Definition at line 149 of file qaxbindable.cpp.

150 {
151  if (!activex)
152  return 0;
153 
154  return activex->clientSite();
155 }
IAxServerBase * activex
Definition: qaxbindable.h:80
virtual IUnknown * clientSite() const =0

◆ createAggregate()

QAxAggregated * QAxBindable::createAggregate ( )
virtual

Reimplement this function when you want to implement additional COM interfaces in the ActiveX control, or when you want to provide alternative implementations of COM interfaces.

Return a new object of a QAxAggregated subclass.

The default implementation returns the null pointer.

Definition at line 165 of file qaxbindable.cpp.

Referenced by QAxServerBase::internalBind().

166 {
167  return 0;
168 }

◆ propertyChanged()

void QAxBindable::propertyChanged ( const char *  property)
protected

Call this function to notify the client that is hosting this ActiveX control that the property property has been changed.

This function is usually called at the end of the property's write function.

See also
requestPropertyChange()

Definition at line 134 of file qaxbindable.cpp.

135 {
136  if (!activex)
137  return;
138 
140 }
virtual void emitPropertyChanged(const char *)=0
IAxServerBase * activex
Definition: qaxbindable.h:80
const char * property
Definition: qwizard.cpp:138

◆ readData()

bool QAxBindable::readData ( QIODevice source,
const QString format 
)
virtual

If the COM object supports a MIME type then this function is called to initialize the COM object from the data source in format.

Since
4.1

You have to open source for reading before you can read from it.

Returns true to indicate success. If the function returns false, then ActiveQt will process the data by setting the properties through the meta object system.

If you reimplement this function you also have to implement writeData(). The default implementation does nothing and returns false.

Warning
ActiveX controls embedded in HTML can use either the type and data attribute of the object tag to read data, or use a list of param tags to initialize properties. If param tags are used, then Internet Explorer will ignore the data attribute, and readData will not be called.
See also
writeData()

Definition at line 214 of file qaxbindable.cpp.

Referenced by QAxServerBase::Load().

215 {
216  Q_UNUSED(source);
217  Q_UNUSED(format);
218  return false;
219 }
#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

◆ reportError()

void QAxBindable::reportError ( int  code,
const QString src,
const QString desc,
const QString context = QString() 
)

Reports an error to the client application.

code is a control-defined error code. desc is a human-readable description of the error intended for the application user. src is the name of the source for the error, typically the ActiveX server name. context can be the location of a help file with more information about the error. If context ends with a number in brackets, e.g. [12], this number will be interpreted as the context ID in the help file.

Definition at line 180 of file qaxbindable.cpp.

181 {
182  if (!activex)
183  return;
184 
185  activex->reportError(code, src, desc, context);
186 }
IAxServerBase * activex
Definition: qaxbindable.h:80
virtual void reportError(int code, const QString &src, const QString &desc, const QString &context)=0

◆ requestPropertyChange()

bool QAxBindable::requestPropertyChange ( const char *  property)
protected

Call this function to request permission to change the property property from the client that is hosting this ActiveX control.

Returns true if the client allows the change; otherwise returns false.

This function is usually called first in the write function for property, and writing is abandoned if the function returns false.

void MyActiveQt::setText(const QString &text)
{
if (!requestPropertyChange("text"))
return;
// update property
propertyChanged("text");
}
See also
propertyChanged()

Definition at line 117 of file qaxbindable.cpp.

118 {
119  if (!activex)
120  return true;
121 
123 }
virtual bool emitRequestPropertyChange(const char *)=0
IAxServerBase * activex
Definition: qaxbindable.h:80
const char * property
Definition: qwizard.cpp:138

◆ writeData()

bool QAxBindable::writeData ( QIODevice sink)
virtual

If the COM object supports a MIME type then this function is called to store the COM object into sink.

Since
4.1

You have to open sink for writing before you can write to it.

Returns true to indicate success. If the function returns false, then ActiveQt will serialize the object by storing the property values.

If you reimplement this function you also have to implement readData(). The default implementation does nothing and returns false.

See also
readData()

Definition at line 241 of file qaxbindable.cpp.

Referenced by QAxServerBase::Save().

242 {
243  Q_UNUSED(sink);
244  return false;
245 }
#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

Friends and Related Functions

◆ QAxServerBase

friend class QAxServerBase
friend

Definition at line 62 of file qaxbindable.h.

Properties

◆ activex

IAxServerBase* QAxBindable::activex
private

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