Linux下Qt Designer 程序设计步骤详解
来源:互联网 发布:前端解析json数组 编辑:程序博客网 时间:2024/06/10 05:49
1、新建文件夹 gotocell。
2、打开qt designer。点击“应用程序”-“编程”-“Qt Designer”;或者在终端里输入命令:designer。
3、选择“File”--“New”,选择“Widget”,然后“Create”。
4、拖入“PushButton” 和“Label”。
5、保存为gotocell.ui ,然后关闭 qt designer 。
6、在gotocell文件夹里右击打开终端,输入命令:uic gotocell.ui -o ui_gotocell.h
7、编写程序,在gotocell文件夹里:
root@caoyin-Lenovo:/home/caoyin/gotocell# qmake -project
root@caoyin-Lenovo:/home/caoyin/gotocell# qmake
root@caoyin-Lenovo:/home/caoyin/gotocell# make
/usr/bin/uic-qt4 gotocelldialog.ui -o ui_gotocelldialog.h
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o gotocelldialog.o gotocelldialog.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o main.o main.cpp
/usr/bin/moc-qt4 -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. gotocelldialog.h -o moc_gotocelldialog.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o moc_gotocelldialog.o moc_gotocelldialog.cpp
g++ -Wl,-O1 -o gotocell gotocelldialog.o main.o moc_gotocelldialog.o -L/usr/lib -lQtGui -lQtCore -lpthread
root@caoyin-Lenovo:/home/caoyin/gotocell# ./gotocell
就能弹出创建的对话框了
2、打开qt designer。点击“应用程序”-“编程”-“Qt Designer”;或者在终端里输入命令:designer。
3、选择“File”--“New”,选择“Widget”,然后“Create”。
4、拖入“PushButton” 和“Label”。
5、保存为gotocell.ui ,然后关闭 qt designer 。
6、在gotocell文件夹里右击打开终端,输入命令:uic gotocell.ui -o ui_gotocell.h
7、编写程序,在gotocell文件夹里:
1) 新建文件main.cpp。输入程序:
#include <QtGui/QApplication> #include "gotocell.h" int main(int argc,char *argv[]) { QApplication a(argc,argv); gotocell hello; hello.show(); return a.exec(); }
2) 新建文件gotocell.h。输入程序:
- #ifndef GOTOCELL_H#define GOTOCELL_H
- #include <QWidget>
- namespace Ui{
- class Form;
- }
- class gotocell:public QWidget
- {
- Q_OBJECT
- public:
- gotocell(QWidget *parent=0);
- ~gotocell();
- private:
- Ui::Form *ui;
- public slots:
- void on_pushButton_clicked();
- }; // 不能少分号,否则出错
- #endif
3) 新建文件gotocell.cpp。输入程序:
8、生成工程文件,编译并运行,如下:
- #include "gotocell.h"
- #include "ui_gotocell.h"
- gotocell::gotocell(QWidget *parent):
- QWidget(parent),
- ui(new Ui::Form)
- {
- ui->setupUi(this);
- }
- gotocell::~gotocell()
- {
- delete ui;
- }
- void gotocell::on_pushButton_clicked()
- {
- ui->label->setText("helloQT");
- }
root@caoyin-Lenovo:/home/caoyin/gotocell# qmake -project
root@caoyin-Lenovo:/home/caoyin/gotocell# qmake
root@caoyin-Lenovo:/home/caoyin/gotocell# make
/usr/bin/uic-qt4 gotocelldialog.ui -o ui_gotocelldialog.h
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o gotocelldialog.o gotocelldialog.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o main.o main.cpp
/usr/bin/moc-qt4 -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. gotocelldialog.h -o moc_gotocelldialog.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o moc_gotocelldialog.o moc_gotocelldialog.cpp
g++ -Wl,-O1 -o gotocell gotocelldialog.o main.o moc_gotocelldialog.o -L/usr/lib -lQtGui -lQtCore -lpthread
root@caoyin-Lenovo:/home/caoyin/gotocell# ./gotocell
就能弹出创建的对话框了
- Linux下Qt Designer 程序设计步骤详解
- Linux下Qt Designer 程序设计步骤详解
- Linux下QT图形界面开发 用快速开发工具Qt Designer编写Qt程序(2)
- ubuntu 下安装 qt designer
- 详解Qt Designer不同容器使用方法
- Linux下安装Eclipse步骤详解
- Linux下安装Eclipse步骤详解
- Linux下安装Eclipse步骤详解
- Linux 下软件安装步骤详解
- linux下安装oracle步骤详解
- Linux下JDK1.6安装步骤详解
- Linux下安装Eclipse步骤详解
- linux/win下安装loadrunner步骤详解
- Linux下安装Eclipse步骤详解
- Linux下创建Django网站 步骤详解
- linux下svn操作及详解步骤
- linux下安装jdk6步骤详解
- linux下安装mysql的步骤详解
- 企业的合同管理对其的重要性
- Ubuntu 7.04 下实现FrameBuffer
- 2011年总结之一—实习篇
- matlab打开时只是一闪logo
- vc++ errors及解决方法
- Linux下Qt Designer 程序设计步骤详解
- Java桌面应用安装部署、安装程序制作(exe4j + Inno Setup)——之三:使用exe4j生成EXE可执行文件
- Unity3D 性能优化工具
- iphone ios行動應用程式開發:iOS平台特性整理
- DataGridView 拖拽到另外一个DataGridView
- 不管你信不信,反正我信了。是这样实现的……
- VC中利用多线程技术实现线程之间的通信 (转)
- SOQL SELECT ALL FIELD
- Java桌面应用安装部署、安装程序制作(exe4j + Inno Setup)——之四:使用Inno Setup制作安装包