第一步:在win上编写好qt程序
第二步:ui布局
第三步:在构造函数中添加自动设置屏幕大小的代码:
//头文件
#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);
第四步:在Ubuntu 上编译qt源码(看我的上一篇文章)
第五步:将qt程序拷贝到Ubuntu上,
第六步:删除工程里面的*.pro.user文件
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#
第七步:生成makefile:
使用我们在Ubuntu上编译好的qt源码下的qmake生成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#
可以看到生成了makefile。最后执行一下make:
生成了可执行文件: