Article directory
0 Preface
The author's research direction involves running code in ubuntu. Earlier, I used the console to run the code file directly. Although I managed to simplify the code into three files in the console, I only need to run these three files in the console. But In the actual scene, it is cumbersome to enter the code to run the execution file. Now I hope to use Qt to write the interface program to encapsulate the code, and then just click the button to use the code function. This article summarizes and records Qt's basic development of desktop software under Ubuntu.
1. Create a new project
2. Write your first program
(1) .pro file configuration
#use to make a executed program
QMAKE_LFLAGS += -no-pie
(2) .ui file design graphical interface
(3) Write code in .cpp file
#include<QMessageBox>
void MainWindow::on_pushButton_clicked()
{
QMessageBox::information(
this,"message","hello, ubuntu Qt!",QMessageBox::Ok,QMessageBox::NoButton);
}
(4) Compile and run the program
3. Start the program outside Qt
Reference materials:
[1] NiUoW. Qt5.12.1 develops a graphical interface under Ubuntu and generates executable files ; 2021-04-01 [accessed 2023-06-28].
[2] weixin_30299539. Ubuntu18 system qt generation program cannot Double-click to run the problem ; 2019-09-12 [accessed 2023-06-28].
[3] The monitor of Class 61. QMessageBox ; 2022-12-04 [accessed 2023-06-28].