1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/doc/src/examples/activeqt/wrapper.qdoc -->
7
<title>Qt 4.0: Wrapper Example (ActiveQt)</title>
8
<style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
9
a:link { color: #004faf; text-decoration: none }
10
a:visited { color: #672967; text-decoration: none }
11
td.postheader { font-family: sans-serif }
12
tr.address { font-family: sans-serif }
13
body { background: #ffffff; color: black; }</style>
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
19
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="annotated.html"><font color="#004faf">Annotated</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">Wrapper Example (ActiveQt)</h1>
23
<li><a href="activeqt-wrapper-main-cpp.html">activeqt/wrapper/main.cpp</a></li>
25
<p>The Wrapper example demonstrates how to export existing <a href="qwidget.html">QWidget</a> classes as ActiveX controls, and the use of <a href="qaxfactory.html">QAxFactory</a> together with the <tt>QAXFACTORY_EXPORT()</tt> macro. ActiveX controls in this example are the standard button classes <a href="qpushbutton.html">QPushButton</a>, <a href="qcheckbox.html">QCheckBox</a> and <a href="qradiobutton.html">QRadioButton</a> as provided by Qt.</p>
26
<pre> class ActiveQtFactory : public QAxFactory
29
ActiveQtFactory( const QUuid &lib, const QUuid &app )
30
: QAxFactory( lib, app )
32
QStringList featureList() const
35
list << "QCheckBox";
36
list << "QRadioButton";
37
list << "QPushButton";
38
list << "QToolButton";
41
QObject *createObject(const QString &key)
43
if ( key == "QCheckBox" )
44
return new QCheckBox(0);
45
if ( key == "QRadioButton" )
46
return new QRadioButton(0);
47
if ( key == "QPushButton" )
48
return new QPushButton(0 );
49
if ( key == "QToolButton" ) {
50
QToolButton *tb = new QToolButton(0);
51
// tb->setIcon( QPixmap(fileopen) );
57
const QMetaObject *metaObject( const QString &key ) const
59
if ( key == "QCheckBox" )
60
return &QCheckBox::staticMetaObject;
61
if ( key == "QRadioButton" )
62
return &QRadioButton::staticMetaObject;
63
if ( key == "QPushButton" )
64
return &QPushButton::staticMetaObject;
65
if ( key == "QToolButton" )
66
return &QToolButton::staticMetaObject;
70
QUuid classID( const QString &key ) const
72
if ( key == "QCheckBox" )
73
return "{6E795DE9-872D-43CF-A831-496EF9D86C68}";
74
if ( key == "QRadioButton" )
75
return "{AFCF78C8-446C-409A-93B3-BA2959039189}";
76
if ( key == "QPushButton" )
77
return "{2B262458-A4B6-468B-B7D4-CF5FEE0A7092}";
78
if ( key == "QToolButton" )
79
return "{7c0ffe7a-60c3-4666-bde2-5cf2b54390a1}";
83
QUuid interfaceID( const QString &key ) const
85
if ( key == "QCheckBox" )
86
return "{4FD39DD7-2DE0-43C1-A8C2-27C51A052810}";
87
if ( key == "QRadioButton" )
88
return "{7CC8AE30-206C-48A3-A009-B0A088026C2F}";
89
if ( key == "QPushButton" )
90
return "{06831CC9-59B6-436A-9578-6D53E5AD03D3}";
91
if ( key == "QToolButton" )
92
return "{6726080f-d63d-4950-a366-9bf33e5cdf84}";
96
QUuid eventsID( const QString &key ) const
98
if ( key == "QCheckBox" )
99
return "{FDB6FFBE-56A3-4E90-8F4D-198488418B3A}";
100
if ( key == "QRadioButton" )
101
return "{73EE4860-684C-4A66-BF63-9B9EFFA0CBE5}";
102
if ( key == "QPushButton" )
103
return "{3CC3F17F-EA59-4B58-BBD3-842D467131DD}";
104
if ( key == "QToolButton" )
105
return "{f4d421fd-4ead-4fd9-8a25-440766939639}";
110
<p>The factory implementation returns the list of supported controls, creates controls on request and provides information about the unique IDs of the COM classes and interfaces for each control.</p>
111
<pre> QAXFACTORY_EXPORT( ActiveQtFactory, "{3B756301-0075-4E40-8BE8-5A81DE2426B7}", "{AB068077-4924-406a-BBAF-42D91C8727DD}" )</pre>
112
<p>The factory is exported using the QAXFACTORY_EXPORT macro.</p>
113
<p>To build the example you must first build the <a href="qaxserver.html#qaxserver">QAxServer</a> library. Then run <tt>qmake</tt> and your make tool in <tt>examples/activeqt/wrapper</tt>.</p>
114
<p>The <a href="qaxserver-demo-wrapper.html">demonstration</a> requires your WebBrowser to support ActiveX controls, and scripting to be enabled.</p>
115
<pre> <SCRIPT LANGUAGE="VBScript">
116
Sub ToolButton_Clicked()
117
RadioButton.text = InputBox( "Enter something", "Wrapper Demo" )
120
Sub PushButton_clicked()
121
MsgBox( "Thank you!" )
124
Sub CheckBox_toggled( state )
126
CheckBox.text = "Check me!"
128
CheckBox.text = "Uncheck me!"
133
A QPushButton:<br />
134
<object ID="PushButton" CLASSID="CLSID:2B262458-A4B6-468B-B7D4-CF5FEE0A7092"
135
CODEBASE="http://www.trolltech.com/demos/wrapperax.cab">
136
<PARAM NAME="text" VALUE="Click me!" />
137
[Object not available! Did you forget to build and register the server?]
138
</object><br />
141
A QCheckBox:<br />
142
<object ID="CheckBox" CLASSID="CLSID:6E795de9-872d-43cf-a831-496ef9d86c68"
143
CODEBASE="http://www.trolltech.com/demos/wrapperax.cab">
144
<PARAM NAME="text" VALUE="Check me!" />
145
[Object not available! Did you forget to build and register the server?]
146
</object><br />
149
A QToolButton:<br />
150
<object ID="ToolButton" CLASSID="CLSID:7c0ffe7a-60c3-4666-bde2-5cf2b54390a1"
151
CODEBASE="http://www.trolltech.com/demos/wrapperax.cab">
152
[Object not available! Did you forget to build and register the server?]
153
</object><br />
156
A QRadioButton:<br />
157
<object ID="RadioButton" CLASSID="CLSID:afcf78c8-446c-409a-93b3-ba2959039189"
158
CODEBASE="http://www.trolltech.com/demos/wrapperax.cab">
159
<PARAM NAME="text" VALUE="Tune me!" />
160
[Object not available! Did you forget to build and register the server?]
161
</object><br /></pre>
162
<p /><address><hr /><div align="center">
163
<table width="100%" cellspacing="0" border="0"><tr class="address">
164
<td width="30%">Copyright © 2005 <a href="trolltech.html">Trolltech</a></td>
165
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
166
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
167
</tr></table></div></address></body>