The first step: write the qt program on win
The second step: ui layout
The third step: add automatic in the constructor Code to set screen size:
//头文件
#include <QDesktopWidget>
#include <QStyle>
#include <QRect>
//自动设置屏幕大小
QDesktopWidget *deskTopWidget = QApplication::desktop();
QRect deskRect = deskTopWidget->availableGeometry();
int appH = deskRect.height();
int appW = deskRect.width();
this->setFixedSize(appW, appH);
setGeometry(0, 0, appW, appH);
Step 4: Compile qt source code on Ubuntu (see my last article)
Step 5: Copy the qt program to Ubuntu,< a i=2> Step 6: Delete the *.pro.user file in the project
root@shen-VirtualBox:/home/shen/qt/project/test02# ls
abc.png main.cpp pic.qrc test02.pro test02.pro.user widget.cpp widget.h widget.ui
root@shen-VirtualBox:/home/shen/qt/project/test02# rm test02.pro.user
root@shen-VirtualBox:/home/shen/qt/project/test02# ls
abc.png main.cpp pic.qrc test02.pro widget.cpp widget.h widget.ui
root@shen-VirtualBox:/home/shen/qt/project/test02#
Step 7: Generate makefile:
Just use qmake under the qt source code we compiled on Ubuntu to generate the makefile.
root@shen-VirtualBox:/home/shen/qt/project/test02# /opt/qt5/bin/qmake
root@shen-VirtualBox:/home/shen/qt/project/test02# ls
abc.png main.cpp Makefile pic.qrc test02.pro widget.cpp widget.h widget.ui
root@shen-VirtualBox:/home/shen/qt/project/test02#
You can see that the makefile is generated. Finally, execute make:
and the executable file is generated: