Home · All Classes · Main Classes · Grouped Classes · Modules · Functions

Wrapper Example (ActiveQt)

Files:

The Wrapper example demonstrates how to export existing QWidget classes as ActiveX controls, and the use of QAxFactory together with the QAXFACTORY_EXPORT() macro. ActiveX controls in this example are the standard button classes QPushButton, QCheckBox and QRadioButton as provided by Qt.

 ** This file is part of the example classes of the Qt Toolkit.
 **
 ** This file may be used under the terms of the GNU General Public
 ** License version 2.0 as published by the Free Software Foundation
 ** and appearing in the file LICENSE.GPL included in the packaging of
 ** this file.  Please review the following information to ensure GNU
 ** General Public Licensing requirements will be met:
 ** http://www.trolltech.com/products/qt/opensource.html
 **
 ** If you are unsure which license is appropriate for your use, please
 ** review the following information:
 ** http://www.trolltech.com/products/qt/licensing.html or contact the
 ** sales department at [email protected].
 **
 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 **
 ****************************************************************************/

 #include <QAxFactory>
 #include <QCheckBox>
 #include <QRadioButton>
 #include <QPushButton>
 #include <QToolButton>
 #include <QPixmap>

 /* XPM */
 static const char *fileopen[] = {
 "    16    13        5            1",
 ". c #040404",
 "# c #808304",
 "a c None",
 "b c #f3f704",
 "c c #f3f7f3",
 "aaaaaaaaa...aaaa",
 "aaaaaaaa.aaa.a.a",
 "aaaaaaaaaaaaa..a",
 "a...aaaaaaaa...a",
 ".bcb.......aaaaa",
 ".cbcbcbcbc.aaaaa",
 ".bcbcbcbcb.aaaaa",
 ".cbcb...........",
 ".bcb.#########.a",
 ".cb.#########.aa",
 ".b.#########.aaa",
 "..#########.aaaa",
 "...........aaaaa"
 };

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.

 class ActiveQtFactory : public QAxFactory
 {
 public:
     ActiveQtFactory( const QUuid &lib, const QUuid &app )
         : QAxFactory( lib, app )
     {}

The factory is exported using the QAXFACTORY_EXPORT macro.

To build the example you must first build the QAxServer library. Then run qmake and your make tool in examples/activeqt/wrapper.

The demonstration requires a web browser that supports ActiveX controls, and scripting to be enabled.

 <SCRIPT LANGUAGE="VBScript">
 Sub ToolButton_Clicked()
     RadioButton.text = InputBox( "Enter something", "Wrapper Demo" )
 End Sub

 Sub PushButton_clicked()
     MsgBox( "Thank you!" )
 End Sub

 Sub CheckBox_toggled( state )
     if state = 0 then
         CheckBox.text = "Check me!"
     else
         CheckBox.text = "Uncheck me!"
     end if
 End Sub
 </SCRIPT>
 <p />
 A QPushButton:<br />
 <object ID="PushButton" CLASSID="CLSID:2B262458-A4B6-468B-B7D4-CF5FEE0A7092"
 CODEBASE="http://www.trolltech.com/demos/wrapperax.cab">
     <PARAM NAME="text" VALUE="Click me!" />
 [Object not available! Did you forget to build and register the server?]
 </object><br />

 <p />
 A QCheckBox:<br />
 <object ID="CheckBox" CLASSID="CLSID:6E795de9-872d-43cf-a831-496ef9d86c68"
 CODEBASE="http://www.trolltech.com/demos/wrapperax.cab">
     <PARAM NAME="text" VALUE="Check me!" />
 [Object not available! Did you forget to build and register the server?]
 </object><br />

 <p />
 A QToolButton:<br />
 <object ID="ToolButton" CLASSID="CLSID:7c0ffe7a-60c3-4666-bde2-5cf2b54390a1"
 CODEBASE="http://www.trolltech.com/demos/wrapperax.cab">
 [Object not available! Did you forget to build and register the server?]
 </object><br />

 <p />
 A QRadioButton:<br />
 <object ID="RadioButton" CLASSID="CLSID:afcf78c8-446c-409a-93b3-ba2959039189"
 CODEBASE="http://www.trolltech.com/demos/wrapperax.cab">
     <PARAM NAME="text" VALUE="Tune me!" />
 [Object not available! Did you forget to build and register the server?]
 </object><br />


Copyright © 2007 Trolltech Trademarks
Qt 4.2.3