当前位置:网站首页>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(); }
边栏推荐
- 局域网无法访问apache服务器
- asp.net大文件分块上传断点续传demo
- 微软100题-天天做-第11题
- Sort 3-select sort and merge sort (recursive implementation + non recursive implementation)
- 【指针内功修炼】字符指针 + 指针数组 + 数组指针 + 指针参数(一)
- 遭MQ连连干翻后的醒悟!含恨码出这份MQ手册助力秋招之旅
- Thoughts on solving the pop-up of malicious computer advertisements
- Ansa secondary development - build ansa/meta secondary development environment on pycharm
- Leetcode topic
- Rosen's QT journey 101 models and views in QT quick
猜你喜欢

HM二次开发 - Data Names及其使用

Sort 3-select sort and merge sort (recursive implementation + non recursive implementation)

Each account corresponds to all passwords, and then each password corresponds to all accounts. How to write the brute force cracking code

解决电脑恶意广告弹窗的思路

Thoughts on solving the pop-up of malicious computer advertisements
![[pointer internal skill cultivation] character pointer + pointer array + array pointer + pointer parameter (I)](/img/e8/2044cae63fe2145ce6294cb1fdfaa0.png)
[pointer internal skill cultivation] character pointer + pointer array + array pointer + pointer parameter (I)

排序5-计数排序

flashfxp 530 User cannot log in. ftp

ANSYS二次开发 - MFC界面调用ADPL文件

使用js直传oss阿里云存储文件,解决大文件上传服务器限制
随机推荐
Each account corresponds to all passwords, and then each password corresponds to all accounts. How to write the brute force cracking code
The little red book of accelerating investment, "rush to medical treatment"?
Headline article_ signature
About the web docking pin printer, lodop uses
Introduction and implementation of queue (detailed explanation)
有趣的 Kotlin 0x0A:Fun with composition
Li Hongyi, machine learning 4. Deep learning
"Wei Lai Cup" 2022 Niuke summer multi school training camp 3 j.journey 0-1 shortest path
Geodetic coordinate system to Martian coordinate system
HyperMesh auto save (enhanced) plug-in instructions
el-input限制只能输入规定的数
C language exception handling mechanism: jump function jump function setjmp/sigsetjmp and longjmp/siglongjmp
IT远程运维是什么意思?远程运维软件哪个好?
Debugging methods of USB products (fx3, ccg3pa)
Reentrant and non reentrant
Record doc
每一个账号对应所有密码,再每一个密码对应所有账号暴力破解代码怎么写?...
PHP image upload
【指针内功修炼】字符指针 + 指针数组 + 数组指针 + 指针参数(一)
排序3-选择排序与归并排序(递归实现+非递归实现)