当前位置:网站首页>First day of QT study
First day of QT study
2022-07-28 16:43:00 【tyrocjl】
( One )Qt relevant
Can be in bash Direct execution
1)assistant(Qt assistant )//Qt Help book
2)qmake(Qt Builder )
3)designer(Qt The designer )// Graphical editing tools
4)uic(Qt Interface converter )// take ui File grab and replace with c++ Code
5)moc(Qt Metaobject compiler )// take qt Syntax extensions revert to standard C++
6)rcc(Qt Resource compiler )// Compile resources such as pictures into C++ Code
7)qtcreator(Qt Creator )//Qt The inheritance development environment of (IDE)Qt Help manual use (assistant)
1) First read the first sentence , Understand the functions of this class , If you don't understand , Sure “more” link , Jump to specify the location .
2) Move on to the header file 、 Build options (QT+=widgets)、 Inheritance relationships
3)Properties( Member variables )
4)Public Functions( Public member functions )
5)Reimplemented Public Functions( Reimplemented public virtual functions )
6)Public Slots( Slot function )//Qt Grammar extension
7)Signals( The signal )//Qt Grammar extension
8)Static Public Members( Static public members )
9)Reimplemented Protected Functions( Protected virtual functions )
10)Detailed Description( Detailed instructions )
( Two ) The first program
- Create a project directory
mkdir Hello
notes : Every Qt Programs should be placed in separate directories - Enter the project directory , Write source code (cpp)
cd Hello
vi main.cpp - perform “qmake -project”, Generate platform independent project files (Hello.pro)
notes : You need to add qmake Build options
QT += widgets // Load in the future widgets Modules correspond to header files and library files - perform “qmake”, According to the previous engineering document , Generate compilation links Makefile
- perform “make”, according to Makefile Complete compilation and linking
- test run “./Hello”
notes : If the code has syntax errors , After modifying the code , Re execution "make" that will do , front 3、4 There is no need to repeat .#include <QApplication> #include <QLabel> int main(int argc,char** argv){ // establish Qt Applications QApplication app(argc,argv); // Create a label control ( Components \ parts \ artifacts ) QLabel label("Hello Qt!"); // Show labels label.show(); // Let the application enter the event loop return app.exec(); }
( 3、 ... and )Qt character string
Common codes
1)linux System default :utf-8
2)windows System default :gbk/gb2312/gb18030
3)Qt Of QSring String default :unicode(utf-16)Code conversion class (QTextCodec)
// establish GBK Coding object
QTextCodec *codec = QTextCodec::codecForName(“GBK”);
// take GBK Convert Chinese string to unicode code
QString string = codec->toUnicode(“GBK Chinese string ”);
notes : If the structure QString String object , If there is no explicit transcoding , It's using utf-8 Of " Constant string " The default is to call fromUtf8 Automatically convert it to Qt For internal use unicode code . Of course , If not utf-8 String , It will also call by default fromUtf8, It's just a mess .
( Four ) The parent window ( Container window )
The parent window can be used to manage the entire interface , When creating a control, you can specify to dock on the parent window , If no parent window is specified, it floats outside to form a separate form .
Common parent window classes
1)QWidget // Graphic control base class
2)QMainWindow // main window (QWidget Subclass )
3)QDialog // Dialog box (QWidget Subclass )QWidget Two common member functions in class
1) Resize the parent window or control
void resize(int w,int h);
2) Adjust the position of the parent window or control
void move(int x,int y);#include <QApplication> #include <QLabel> #include <QPushButton> #include <QWidget> #include <QDialog> #include <QMainWindow> #include <QFont>// typeface int main(int argc,char** argv){ QApplication app(argc,argv); // Create a parent window object //QWidget parent; //QDialog parent; QMainWindow parent; // Set the font size of the parent window QFont font; font.setPointSize(20); parent.setFont(font); // Set the size and position of the parent window parent.resize(480,320); parent.move(200,100); // establish label And dock on the parent window QLabel label(" I'm the label ",&parent); label.move(50,50); label.resize(150,50); // establish button And dock on the parent window QPushButton button(" I'm the button ",&parent); button.move(50,200); button.resize(150,50); // Dynamically create button And dock on the parent window // When the parent window is destroyed , The dynamic objects docked above will be automatically //delete, There is no need to perform... Manually detele. QPushButton* button2 = new QPushButton(" Me too ",&parent); button2->move(300,200); button2->resize(150,50); // Show parent window , The controls docked above will also be displayed together parent.show(); return app.exec(); }
边栏推荐
- php关于数据量大导出数据或者遍历数据导致内存溢出超时等问题
- El input limit can only input the specified number
- Microsoft question 100 - do it every day - question 16
- Record doc
- 重置grafana登录密码为默认密码
- Thoughts on solving the pop-up of malicious computer advertisements
- WSL+Valgrind+Clion
- HyperMesh运行脚本文件的几种方法
- Qt学习之Qt Designer(设计师)
- Wechat official account to obtain material list
猜你喜欢

【指针内功修炼】字符指针 + 指针数组 + 数组指针 + 指针参数(一)

I can only sell the company after the capital has been "cut off" for two years

Debugging methods of USB products (fx3, ccg3pa)

SCI scientific paper writing Growth Camp (full version)

ANSA二次开发 - Apps和ANSA插件管理

有趣的 Kotlin 0x09:Extensions are resolved statically

Sort 4-heap sort and massive TOPK problem

LeetCode每日一练 —— 160. 相交链表

ANSA二次开发 - Visual Studio Code上搭建ANSA二次开发环境

Ansa secondary development - build ansa/meta secondary development environment on pycharm
随机推荐
解决uniapp等富文本图片宽度溢出
一小时内学会Abaqus脚本编程秘籍
Microsoft question 100 - do it every day - question 11
laravel
PHP 图片上传
Detailed record of steps to configure web server (many references)
解决电脑恶意广告弹窗的思路
有趣的 Kotlin 0x09:Extensions are resolved statically
HDU1847解题思路
CRC16 data verification supports modelbus and XMODEM verification modes (C language)
nowcode-学会删除链表中重复元素两题(详解)
Reentrant and non reentrant
Qt学习之Qt Designer(设计师)
Splash (渲染JS服务)介绍安装
有趣的 Kotlin 0x0A:Fun with composition
局域网无法访问apache服务器
mysql cdc 如果binlog日志文件不全,全量阶段能读到所有数据吗
500million users, four years earlier than wechat... This app, which has been in operation for 15 years, will be permanently discontinued
一大早支付宝来短信说你中“奖”了?处理服务器挖矿病毒 - kthreaddi
关于MIT6.828_HW9_barriers xv6 homework9的一些问题