How does Qt develop desktop software under Ubuntu?

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.
  insert image description here

1. Create a new project

  insert image description here

  insert image description here

2. Write your first program

  (1) .pro file configuration
  insert image description here

#use to make a executed program
QMAKE_LFLAGS += -no-pie

  (2) .ui file design graphical interface
  insert image description here

  (3) Write code in .cpp file
  insert image description here

#include<QMessageBox>
  
void MainWindow::on_pushButton_clicked()  
{
    
      
    QMessageBox::information(  
            this,"message","hello, ubuntu Qt!",QMessageBox::Ok,QMessageBox::NoButton);  
}

  (4) Compile and run the program
  insert image description here

3. Start the program outside Qt

  insert image description here

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].

Guess you like

Origin blog.csdn.net/qq_40640910/article/details/131441104