source: trunk/src/activeqt/container/qaxobject.cpp@ 792

Last change on this file since 792 was 651, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 5.8 KB
RevLine 
[2]1/****************************************************************************
2**
[651]3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
[561]4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
[2]6**
7** This file is part of the ActiveQt framework of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:BSD$
10** You may use this file under the terms of the BSD license as follows:
11**
12** "Redistribution and use in source and binary forms, with or without
13** modification, are permitted provided that the following conditions are
14** met:
15** * Redistributions of source code must retain the above copyright
16** notice, this list of conditions and the following disclaimer.
17** * Redistributions in binary form must reproduce the above copyright
18** notice, this list of conditions and the following disclaimer in
19** the documentation and/or other materials provided with the
20** distribution.
21** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22** the names of its contributors may be used to endorse or promote
23** products derived from this software without specific prior written
24** permission.
25**
26** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41#include "qaxobject.h"
42
43#ifndef QT_NO_WIN_ACTIVEQT
44
45#include <quuid.h>
46#include <qmetaobject.h>
47#include <qstringlist.h>
48
49#include <windows.h>
50
51QT_BEGIN_NAMESPACE
52
53/*!
54 \class QAxObject
55 \brief The QAxObject class provides a QObject that wraps a COM object.
56
57 \inmodule QAxContainer
58
59 A QAxObject can be instantiated as an empty object, with the name
60 of the COM object it should wrap, or with a pointer to the
61 IUnknown that represents an existing COM object. If the COM object
62 implements the \c IDispatch interface, the properties, methods and
63 events of that object become available as Qt properties, slots and
64 signals. The base class, QAxBase, provides an API to access the
65 COM object directly through the IUnknown pointer.
66
67 QAxObject is a QObject and can be used as such, e.g. it can be
68 organized in an object hierarchy, receive events and connect to
69 signals and slots.
70
71 QAxObject also inherits most of its ActiveX-related functionality
72 from QAxBase, notably dynamicCall() and querySubObject().
73
74 \warning
75 You can subclass QAxObject, but you cannot use the Q_OBJECT macro
76 in the subclass (the generated moc-file will not compile), so you
77 cannot add further signals, slots or properties. This limitation is
78 due to the metaobject information generated in runtime.
79 To work around this problem, aggregate the QAxObject as a member of
80 the QObject subclass.
81
82 \sa QAxBase, QAxWidget, QAxScript, {ActiveQt Framework}
83*/
84
85/*!
86 Creates an empty COM object and propagates \a parent to the
87 QObject constructor. To initialize the object, call \link
88 QAxBase::setControl() setControl \endlink.
89*/
90QAxObject::QAxObject(QObject *parent)
91: QObject(parent)
92{
93}
94
95/*!
96 Creates a QAxObject that wraps the COM object \a c. \a parent is
97 propagated to the QObject constructor.
98
99 \sa setControl()
100*/
101QAxObject::QAxObject(const QString &c, QObject *parent)
102: QObject(parent)
103{
104 setControl(c);
105}
106
107/*!
108 Creates a QAxObject that wraps the COM object referenced by \a
109 iface. \a parent is propagated to the QObject constructor.
110*/
111QAxObject::QAxObject(IUnknown *iface, QObject *parent)
112: QObject(parent), QAxBase(iface)
113{
114}
115
116/*!
117 Releases the COM object and destroys the QAxObject,
118 cleaning up all allocated resources.
119*/
120QAxObject::~QAxObject()
121{
122 clear();
123}