湖北长欣建设有限公司网站,产品网站 模板,成都企业网站建设,京东云服务器QT高级编程
主要从以下几个方面来介绍QT高级编程#xff0c;并介绍QT相关的概念。
1、 QT部件Widget#xff1b; 2、 QT信号与槽机制#xff1b; 3、 对象树关系#xff1b; 4、 布局管理#xff1b; 5、标准对话框以及自定义对话框#xff1b; 6、文件与目录#xff…QT高级编程
主要从以下几个方面来介绍QT高级编程并介绍QT相关的概念。
1、 QT部件Widget 2、 QT信号与槽机制 3、 对象树关系 4、 布局管理 5、标准对话框以及自定义对话框 6、文件与目录 7、数据库编程 8、级联样式表 9、事件与绘画 10、二维图形 11、网络 12、Webkit Web 开发 13、进程与线程 14、跨平台 15、模型与视图 16、音频与多媒体 17、其他 一.介绍
Qt是一个跨平台的C图形用户界面应用程序开发框架。Qt类结构框架图掌握主要的类的使用QTabWidget、QLabel、QTextEdit(多行)、QLineEdit、QBushiButton、QGroupBox、QTableWidget(表格)、QCheckBox(复选框)、QRadioButton(单选按钮)。QHBoxLayout(水平布局)QVBoxLayout(垂直布局)通过Qt Creator中的帮助可以查看开发文档通过设置索引、目录等可以搜索查看相关类的使用。在通过Qt Creator创建工程时注意工程路径为全英文路径避免中文路径。
二、案例 1.通过Qt编程实现如下窗口。 2.源代码及其编译运行
#include QApplication
#includeQLineEdit
#includeQPushButton
#includeQLabel
#includeQWidget
#includeQHBoxLayout
#includeQVBoxLayout
int main(int argc,char**argv)
{QApplication app(argc,argv);//创建组件QLabel *value new QLabel;value-setText(Window will open the corresponding program, folder, document or\nInternet resource for you according to the name you entered.);QLabel *cmd new QLabel;cmd-setText(Open(O):);QLineEdit *lineEdit new QLineEdit;lineEdit-clear();QPushButton *submit new QPushButton;submit-setText(Ok);QPushButton *cancel new QPushButton;cancel-setText(Cancel);QPushButton *browser new QPushButton;browser-setText(Browser);QHBoxLayout *cmdLayout new QHBoxLayout;cmdLayout-addWidget(cmd);cmdLayout-addWidget(lineEdit);//创建布局添加组件QHBoxLayout *buttonLayout new QHBoxLayout;buttonLayout-addWidget(submit);buttonLayout-addWidget(cancel);buttonLayout-addWidget(browser);QVBoxLayout *mainLayout new QVBoxLayout;mainLayout-addWidget(value);mainLayout-addLayout(cmdLayout);mainLayout-addLayout(buttonLayout);//创建主窗口并添加布局QWidget *window new QWidget;window-setLayout(mainLayout);window-setWindowTitle(Run);window-show();return app.exec();
}打开Qt Creator中的MinGW命令窗口并进入到源码所在目录通过如下命令生成.pro文件。
qmake -projec执行qmake生成makefile文件。
qmake通过如下命令编译连接生成可执行文件。
mingw32-make3.可能遇到的问题 QApplication: No such file or directory由于Qt5将大部分桌面部件移到了Qt Widgets模块中即QApplication已经从原来的QtGui/QApplication移动到QtWidgets/QApplication
//解决办法在.pro文件中添加如下语句
greaterThan(QT_MAJOR_VERSION, 4): QT widgets问题解决https://blog.csdn.net/friendbkf/article/details/45440175
4.运行结果如下是通过Qt Creator打开.pro工程执行的结果。 5.qmake使用 https://www.cnblogs.com/xiangtingshen/p/12095924.html