Copyright Notice
Respect Original Works. Reprinted, please maintain the integrity of the article, and in the form of a hyperlink to indicate the original author "tingsking18" and the main site address, so that other friends can ask and correct.
Mixed MFC and QT programming-use QT components in the MFC Program
1. Create a simpleMFC DialogProgram.
2. InBool ctestapp: initinstance ()Add to function
Qmfcapp: instance (this );
Tracking qmfcapp
The function of the static function is to create a qapplication.
Instance.
3.
Override the run method of ctestapp.
As follows:
int CTestApp::Run() { int result = QMfcApp::run(this); delete qApp; return result;}
I am not sure what it means.
Qt help:
QMfcApp:run() will then use that QMfcApp::instance, which must then be deleted explicitly using the global qApp pointer.
I have no idea what it means.
4.
In the testdlg. h file, define qwinwidget * widget; 5.
Then it's easy.
Add widget = new qwinwidget (this) to the oncreate function of ctestdialog );
QHBoxLayout *hbox = new QHBoxLayout( widget );
Qlabel * label = new qlabel ("Enter text:", widget); qlineedit * edit = new qlineedit (widget); hbox-> addwidget (Label ); hbox-> addwidget (edit); widget-> move (0, 0); widget-> show ();6.
InCtestdialogOfOndestroyMethod:
Delete widget;
Widget = 0;
7. InQmake-ProjectGenerated. ProFile:
Defines-= Unicode
Defines + = _ afxdll winver = 0x0500
Include (../src/qtwinmigrate. PRI)
Otherwise, it cannot be compiled.
8. Qmake nmakeRun