Nesta página

QAxAggregated Class

A classe QAxAggregated é uma classe base abstrata para implementações de interfaces COM adicionais. Mais...

Cabeçalho: #include <qaxaggregated.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS AxServer)
target_link_libraries(mytarget PRIVATE Qt6::AxServer)
qmake: QT += axserver

Funções públicas

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

Funções protegidas

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

Descrição detalhada

Crie uma subclasse de QAxAggregated e reimplemente queryInterface() para oferecer suporte a interfaces COM adicionais. Utilize herança múltipla dessas interfaces COM. Implemente a interface IUnknown dessas interfaces COM, delegando as chamadas para QueryInterface(), AddRef() e Release() à interface fornecida por controllingUnknown().

Utilize o método widget() caso precise realizar chamadas para o QWidget que implementa o controle ActiveX. Você não deve armazenar esse ponteiro em sua subclasse (a menos que utilize QPointer), pois o QWidget pode ser destruído pela estrutura ActiveQt a qualquer momento.

Veja também QAxBindable, QAxFactory e Active Qt.

Documentação das funções de membro

[constexpr noexcept protected default] QAxAggregated::QAxAggregated()

Constrói, por padrão, uma instância de ` QAxAggregated`.

[virtual constexpr noexcept protected default] QAxAggregated::~QAxAggregated()

O destrutor é chamado internamente pelo Qt.

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

Retorna a interface ` IUnknown ` do controle ActiveX. Implemente a interface ` IUnknown ` em sua subclasse ` QAxAggregated ` para delegar as chamadas a ` QueryInterface()`, ` AddRef()` e ` Release() ` à interface fornecida por esta função.

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

ulong AxImpl::AddRef()
{
    return controllingUnknown()->AddRef();
}

ulong AxImpl::Release()
{
    return controllingUnknown()->Release();
}

Em vez de declarar e implementar essas três funções manualmente, você pode usar a macro QAXAGG_IUNKNOWN na declaração de classe da sua subclasse.

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

Retorna um ponteiro para a subclasse ` QObject ` que implementa o objeto COM. Esta função pode retornar 0.

Aviso: Você não deve armazenar o ponteiro retornado, a menos que utilize um ` QPointer`, pois o ` QObject ` pode ser destruído pelo ActiveQt a qualquer momento.

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

Reimplemente esta função virtual pura para oferecer suporte a interfaces COM adicionais. Defina o valor de ` iface ` para que aponte a este objeto, a fim de oferecer suporte à interface ` iid`. Observe que é necessário converter o ponteiro ` this ` para a superclasse apropriada.

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;
}

Retorne os resultados padrão do COM: ` S_OK ` (a interface é suportada) ou ` E_NOINTERFACE ` (a interface solicitada não é suportada).

Aviso: Embora seja necessário implementar a interface IUnknown ao implementar qualquer interface COM, você não deve oferecer suporte à interface IUnknown em sua implementação de queryInterface().

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

Retorna um ponteiro para a subclasse ` QWidget ` que implementa o controle ActiveX. Esta função pode retornar 0.

Atenção: Você não deve armazenar o ponteiro retornado, a menos que utilize um ` QPointer`, pois o ` QWidget ` pode ser destruído pelo ActiveQt a qualquer momento.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.