This article demonstrates how to package the Qt application into IE and publish it.
1. Example Qt program:
Create a project and select the Qt Library type. The class name is ClassDemo.
Create a new QtGui class (inheriting QWidge) Class Name ClassGui and add QLabel or QPushButton to the ClassGui ui.
Add a member variable pointer of the ClassGui type in ClassDemo, add a public member function GetWidget, and return the pointer.
Compile and generate the dynamic library classdemo. dll.
2. Shell Qt program:
Create a project and select the ActiveQtServer type. The class name is ClassServer.
Add a member variable pointer of the ClassDemo type to ClassServer. Add the following code to the constructor:
M_classdemo = new ClassDemo (this );
QLayout * exist_layout = this-> layout ();
If (exist_layout)
{
Delete exist_layout;
}
QGridLayout * layout = new QGridLayout;
Layout-> addWidget (m_classdemo-> GetWidget (), 0, 0 );
Layout-> setContentsMargins (0, 0, 0, 0 );
This-> setLayout (layout );
Compile and generate the dynamic library classserver. dll.
3. Compile the installation information file classserver. inf
Find all libraries dependent on classserver. dll, which may include the following:
Classserver. dll
Classdemo. dll
QtGuid4.dll
QtCored4.dll
Msvcp90d. dll
Msvcr90d. dll
The file content is as follows:
[Version]
Signature = "$ CHICAGO $"
AdvancedINF = 2.0
[Add. Code]
Classdemo. dll = classdemo. dll
Classserver. dll = classserver. dll
QtGuid4.dll = QtGuid4.dll
QtCored4.dll = QtCored4.dll
Msvcp90d. dll = msvcp90d. dll
Msvcr90d. dll = msvcr90d. dll
[Classdemo. dll]
File-win32-x86 = thiscab
[QtGuid4.dll]
File-win32-x86 = thiscab
[QtCored4.dll]
File-win32-x86 = thiscab
[Msvcp90d. dll]
File-win32-x86 = thiscab
DestDir = 11
[Msvcr90d. dll]
File-win32-x86 = thiscab
DestDir = 11
[Classserver. dll]
File-win32-x86 = thiscab
Clsid = {AAF5BD93-5D87-4741-8804-A8869DF7048A}
FileVersion = 1, 3, 1, 0
RegisterServer = yes
The value of clsid can be found in classserver. cpp: the first of five in QAXFACTORY_DEFAULT.
4. Packaging:
Download the cab packaging tool (link: http://download.csdn.net/detail/fm0517/5114431 ).
Run the following command:
Cabarc. Exe n cabname. cab classdemo. dll classserver. dll QtGuid4.dll QtCored4.dll msvcp90d. dll msvcr90d. dll classserver. inf
Cabname. cab is the name of the cab package, and the following parameters are all related dynamic libraries and installation information files.
5. write html files:
Example:
<HTML>
<HEAD>
<TITLE> New Page </TITLE>
</HEAD>
<BODY>
<Br> </br>
<Object ID = "QSimpleAX" width = 500 height = 300 CLASSID = "CLSID: AAF5BD93-5D87-4741-8804-A8869DF7048A" CODEBASE = "cabname. cab"> </object>
</BODY>
</HTML>
The CLSID is the same as the clsid in the inf file. CODEBASE is the name of the cab package.
You must put the cab package and html file in the same directory.
6. Release:
Install apache or tomcat and place the cab package and html in the corresponding directory.
Once packaged as a cab, you do not need to run Regsvr registration on the local machine.