Qt5 C++ First GUI Application

In this Qt5 C++ article i want to show creating First GUI Application. so now lets get started Before this you can check previous articles on Qt5 C++ GUI Development.

 

You can check the tutorials in the below link.

Qt5 C++ GUI Development

 

 

How to Create First GUI Application in Qt5 C++?

For creating your first GUI application in Qt5 using C++, you can follow these steps:

  1. Install Qt5: If you haven’t already, download and install the Qt framework from the official website: https://www.qt.io/download
  2. Open Qt Creator: Launch the Qt Creator IDE.
  3. Create a New Project:
    • Click on “File” > “New File or Project”.
    • Choose “Application” under “Projects” and click “Next”.
    • Select “Qt Widgets Application” and click “Choose…”.
    • Enter a name for your project and choose a location to save it. Click “Next” and then “Finish”.
  4. Design the User Interface (UI):
    • In the Design mode, you can drag and drop widgets from the Widget Box to the main window to design your UI.
    • Customize the widgets and arrange them as desired.
  5. Add Functionality (Optional):
    • Switch to the “Edit” mode to edit the code associated with your UI.
    • Implement functionality by connecting signals (events) from widgets to slots (functions).
  6. Build and Run:
    • After that your UI and functionality are implemented, click on the green play button to build and run your application.
    • Ensure that your application runs as expected.

 

 

 

OK first of all you need to create a new Project in your Qt5 framework after that you need to choose Qt Widget Application after that click on next and finish your project

Qt5 C++ GUI Application
Qt5 C++ GUI Application

 

 

 

 

So after creating your project you will have some files in your project let me describe these files.

Qt5 GUI Development
Qt5 GUI Development

 

 

the first one is  .PRO file, Project file created using the Qt software development toolkit (SDK), which allows developers to create cross-platform applications; contains all the information necessary to compile a Qt application with the Qt qmake command.

PRO files include references to project libraries, assets, and source code files, as well as other files such as application resources (.QRC files), project includes (.PRI files), translation sources (.TS files), phrase books (.QPH files), and style sheets (.QSS files).Qt projects are used for creating applications that run on the Qt framework.

 

Qt5 QMake
Qt5 QMake

 

 

 

This is the header file mainwindow.h, in every Qt5 GUI application we have one header file to cpp files.

 

 

 

Now our main.cpp file, in this file we have our gui logic  and we don’t need to bring changes in this file.

 

 

And  this is mainwindow.cpp for our header file

 

 

 

And the last and important file is the mainwindow.ui, this is the file that we design our GUI application in here. and you can see we have added a QPushButton in this .ui file.

Qt QPushButton
Qt QPushButton

 

 

 

Run the project and this will be the result

Qt5 C++ First GUI Application
Qt5 C++ First GUI Application

Subscribe and Get Free Video Courses & Articles in your Email

 

Leave a Comment

Share via
Copy link
Powered by Social Snap
×