Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

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 sales@trolltech.com.
 **
 ** 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 />

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 53
  2. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  4. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le blog Digia au hasard

Logo

Déploiement d'applications Qt Commercial sur les tablettes Windows 8

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.2
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web