QAxContainer ModuleThe QAxContainer module is a Windows-only extension for accessing ActiveX controls and COM objects. More... Classes
Detailed DescriptionThe QAxContainer module is part of the ActiveQt framework. It provides a library implementing a QWidget subclass, QAxWidget, that acts as a container for ActiveX controls, and a QObject subclass, QAxObject, that can be used to easily access non-visual COM objects. Scripting COM objects embedded using these classes is possible through the QAxScript, QAxScriptManager and QAxScriptEngine classes, and a set of tools makes it easy to access COM objects programmatically. The module consists of six classes
Some example applications that use standard ActiveX controls to provide high-level user interface functionality are provided. The QAxContainer module is part of the Qt Desktop Edition for Windows. It is not part of the Qt Open Source Edition. Topics:
Using the LibraryTo build Qt applications that can host COM objects and ActiveX controls link the application against the QAxContainer module by adding CONFIG += qaxcontainer to your application's .pro file. Distributing QAxContainer ApplicationsThe QAxContainer library is static, so there is no need to redistribute any additional files when using this module. Note however that the ActiveX server binaries you are using might not be installed on the target system, so you have to ship them with your package and register them during the installation process of your application. Instantiating COM ObjectsTo instantiate a COM object use the QAxBase::setControl() API, or pass the name of the object directly into the constructor of the QAxBase subclass you are using. The control can be specified in a variety of formats, but the fastest and most powerful format is to use the class ID (CLSID) of the object directly. The class ID can be prepended with information about a remote machine that the object should run on, and can include a license key for licensed controls. Typical Error MessagesActiveQt prints error messages to the debug output when it encounters error situations at runtime. Usually you must run your program in the debugger to see these messages (e.g. in Visual Studio's Debug output). Requested control could not be instantiatedThe control requested in QAxBase::setControl() is not installed on this system, or is not accessible for the current user. The control might require administrator rights, or a license key. If the control is licensed, pass the license key to QAxBase::setControl as documented. Accessing the Object APIActiveQt provides a Qt API to the COM object, and replaces COM datatypes with Qt equivalents. There are four ways to call APIs on the COM object:
Generating a C++ NamespaceTo generate a C++ namespace for the type library you want to access, use the dumpcpp tool. Run this tool manually on the type library you want to use, or integrate it into the build system by adding the type libraries to the TYPELIBS variable in your application's .pro file: TYPELIBS = file.tlb Note that dumpcpp might not be able to expose all APIs in the type library. Include the resulting header file in your code to access the object APIs through the generated C++ classes. See the Qutlook example for more information. Call-by-NameUse QAxBase::dynamicCall() and QAxBase::querySubObject() as well as the QObject::setProperty() and QObject::property() APIs to call the methods and properties of the COM object through their name. Use the dumpdoc tool to get the documentation of the Qt API for any COM object and its subobjects; note that not all of the COM object's APIs might be available. See the Webbrowser example for more information. Calling Function Through a Script EngineA Qt application can host any ActiveScript engine installed on the system. The script engine can then run script code that accesses the COM objects. To instantiate a script engine, use QAxScriptManager::addObject() to register the COM objects you want to access from script, and QAxScriptManager::load() to load the script code into the engine. Then call the script functions using QAxScriptManager::call() or QAxScript::call(). Which APIs of the COM object are available through scripting depends on the script language used. The ActiveX Test Container demonstrates loading of script files. Calling a Function Using the Native COM InterfacesTo call functions of the COM object that can not be accessed via any of the above methods it is possible to request the COM interface directly using QAxBase::queryInterface(). To get a C++ definition of the respective interface classes use the #import directive with the type library provided with the control; see your compiler manual for details. Typical Error MessagesActiveQt prints error messages to the debug output when it encounters error situations at runtime. Usually you must run your program in the debugger to see these messages (e.g. in Visual Studio's Debug output). QAxBase::internalInvoke: No such methodA QAxBase::dynamicCall() failed - the function prototype did not match any function available in the object's API. Error calling IDispatch member: Non-optional parameter missingA QAxBase::dynamicCall() failed - the function prototype was correct, but too few parameters were provided. Error calling IDispatch member: Type mismatch in parameter nA QAxBase::dynamicCall() failed - the function prototype was correct, but the paramter at index n was of the wrong type and could not be coerced to the correct type. QAxScriptManager::call(): No script provides this functionYou try to call a function that is provided through an engine that doesn't provide introspection (ie. ActivePython or ActivePerl). You need to call the function directly on the respective QAxScript object. See also ActiveQt Framework. [Previous: QtTest Module] [Qt's Modules] [Next: QAxServer Module] |
Publicité
Best OfActualités les plus luesSemaine
Mois
Année
Le Qt Labs au hasardSémantique d'ordonnancement mémoire et opérations atomiques dans QtLes Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.
CommunautéRessources
Liens utilesContact
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.3 | |
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 ! |
Copyright © 2000-2012 - www.developpez.com