QAxAggregated 类

QAxAggregated 类是实现额外 COM 接口的抽象基类。 更多...

头: #include <QAxAggregated>
CMake: find_package(Qt6 COMPONENTS AxServer REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::AxServer)
qmake: QT += axserver

公共函数

virtual long queryInterface (const QUuid & iid , void ** iface ) = 0

保护函数

virtual ~QAxAggregated ()
IUnknown * controllingUnknown () const
QObject * object () const
QWidget * widget () const

详细描述

Create a subclass of QAxAggregated and reimplement queryInterface () to support additional COM interfaces. Use multiple inheritance from those COM interfaces. Implement the IUnknown interface of those COM interfaces by delegating the calls to QueryInterface() , AddRef() and Release() to the interface provided by controllingUnknown ().

使用 widget () method if you need to make calls to the QWidget implementing the ActiveX control. You must not store that pointer in your subclass (unless you use QPointer ), as the QWidget can be destroyed by the ActiveQt framework at any time.

另请参阅 QAxBindable , QAxFactory ,和 Active Qt .

成员函数文档编制

[virtual protected] QAxAggregated:: ~QAxAggregated ()

The destructor is called internally by Qt.

[protected] IUnknown *QAxAggregated:: controllingUnknown () const

返回 IUnknown interface of the ActiveX control. Implement the IUnknown interface in your QAxAggregated subclass to delegate calls to QueryInterface() , AddRef() ,和 Release() to the interface provided by this function.

HRESULT AxImpl::QueryInterface(REFIID iid, void **iface)
{
    return controllingUnknown()->QueryInterface(iid, iface);
}
ulong AxImpl::AddRef()
{
    return controllingUnknown()->AddRef();
}
ulong AxImpl::Release()
{
    return controllingUnknown()->Release();
}
					

Instead of declaring and implementing these three functions manually, you can use the QAXAGG_IUNKNOWN macro in the class declaration of your subclass.

[protected] QObject *QAxAggregated:: object () const

返回指针指向 QObject subclass implementing the COM object. This function might return 0.

警告: You must not store the returned pointer, unless you use a QPointer , since the QObject can be destroyed by ActiveQt at any time.

[pure virtual] long QAxAggregated:: queryInterface (const QUuid & iid , void ** iface )

Reimplement this pure virtual function to support additional COM interfaces. Set the value of iface to point to this object to support the interface iid . Note that you must cast the this pointer to the appropriate superclass.

long AxImpl::queryInterface(const QUuid &iid, void **iface)
{
    *iface = 0;
    if (iid == IID_ISomeCOMInterface)
        *iface = (ISomeCOMInterface*)this;
    else
        return E_NOINTERFACE;
    AddRef();
    return S_OK;
}
					

Return the standard COM results S_OK (interface is supported) or E_NOINTERFACE (requested interface is not supported).

警告: Even though you must implement the IUnknown interface if you implement any COM interface you must not support the IUnknown interface in your queryInterface() implementation.

[protected] QWidget *QAxAggregated:: widget () const

返回指针指向 QWidget subclass implementing the ActiveX control. This function might return 0.

警告: You must not store the returned pointer, unless you use a QPointer , since the QWidget can be destroyed by ActiveQt at any time.