Qt 4.8
qaxobject.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the ActiveQt framework of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
10 **
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
13 ** met:
14 ** * Redistributions of source code must retain the above copyright
15 ** notice, this list of conditions and the following disclaimer.
16 ** * Redistributions in binary form must reproduce the above copyright
17 ** notice, this list of conditions and the following disclaimer in
18 ** the documentation and/or other materials provided with the
19 ** distribution.
20 ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21 ** of its contributors may be used to endorse or promote products derived
22 ** from this software without specific prior written permission.
23 **
24 **
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40 
41 #ifndef QAXOBJECT_H
42 #define QAXOBJECT_H
43 
44 #include <ActiveQt/qaxbase.h>
45 
47 
49 
50 QT_MODULE(ActiveQt)
51 
52 #ifndef QT_NO_WIN_ACTIVEQT
53 
54 class QAxObject : public QObject, public QAxBase
55 {
56  friend class QAxEventSink;
57 public:
58  const QMetaObject *metaObject() const;
59  void* qt_metacast(const char*);
60  int qt_metacall(QMetaObject::Call, int, void **);
61  QObject* qObject() const { return (QObject*)this; }
62  const char *className() const;
63 
64  QAxObject(QObject *parent = 0);
65  QAxObject(const QString &c, QObject *parent = 0);
66  QAxObject(IUnknown *iface, QObject *parent = 0);
67  ~QAxObject();
68 
69  bool doVerb(const QString &verb);
70 
71 protected:
72  void connectNotify(const char *signal);
73 
74 private:
75  const QMetaObject *parentMetaObject() const;
77 };
78 
79 #if defined Q_CC_MSVC && _MSC_VER < 1300
80 template <> inline QAxObject *qobject_cast_helper<QAxObject*>(const QObject *o, QAxObject *)
81 #else
82 template <> inline QAxObject *qobject_cast<QAxObject*>(const QObject *o)
83 #endif
84 {
85  void *result = o ? const_cast<QObject *>(o)->qt_metacast("QAxObject") : 0;
86  return (QAxObject*)(result);
87 }
88 
89 #if defined Q_CC_MSVC && _MSC_VER < 1300
90 template <> inline QAxObject *qobject_cast_helper<QAxObject*>(QObject *o, QAxObject *)
91 #else
92 template <> inline QAxObject *qobject_cast<QAxObject*>(QObject *o)
93 #endif
94 {
95  void *result = o ? o->qt_metacast("QAxObject") : 0;
96  return (QAxObject*)(result);
97 }
98 
101 
102 #endif // QT_NO_WIN_ACTIVEQT
103 
105 
106 #endif // QAXOBJECT_H
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
QAxObject(QObject *parent=0)
Creates an empty COM object and propagates parent to the QObject constructor.
Definition: qaxobject.cpp:93
void signal(const QString &, int, void *)
This generic signal gets emitted when the COM object issues the event name.
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
int qt_metacall(QMetaObject::Call, int, void **)
Definition: qaxobject.cpp:165
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QAxObject class provides a QObject that wraps a COM object.
Definition: qaxobject.h:54
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
bool doVerb(const QString &verb)
Requests the COM object to perform the action verb.
Definition: qaxobject.cpp:197
const QMetaObject * metaObject() const
Definition: qaxobject.cpp:131
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void connectNotify()
Connects to all event interfaces of the object.
Definition: qaxbase.cpp:3282
void * qt_metacast(const char *)
Definition: qaxobject.cpp:147
#define Q_DECLARE_METATYPE(TYPE)
This macro makes the type Type known to QMetaType as long as it provides a public default constructor...
Definition: qmetatype.h:265
static QMetaObject staticMetaObject
Definition: qaxobject.h:76
const char * className() const
Definition: qaxobject.cpp:157
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
#define QT_END_HEADER
Definition: qglobal.h:137
~QAxObject()
Releases the COM object and destroys the QAxObject, cleaning up all allocated resources.
Definition: qaxobject.cpp:123
The QAxBase class is an abstract class that provides an API to initialize and access a COM object...
Definition: qaxbase.h:66
QObject * qObject() const
Definition: qaxobject.h:61
const QMetaObject * parentMetaObject() const
Definition: qaxobject.cpp:139