How to Create Your First Qt Program on Ubuntu Linux
The Qt (SDK) software development kit is a portable cross platform application user interface framework which works on the Windows, Linux and Mac OS X operating systems. Qt SDK helps you create graphical user interfaces (GUI's) for your...
Method 1 of 1:
Qt 4.8 SDK Compilation Instructions
- For this exercise we are going to open up a terminal on Ubuntu Linux and issue the following command which will create the main directory for a Qt program.
- Type/Copy/Paste: mkdir QtHelloWorld
- Change into your QtHelloWorld directory by issuing the following command
- Type/Copy/Paste: cd QtHelloWorld
- This is very important to make sure you are in the correct directory when creating your Qt program.
- While we are in the QtHelloWorld directory, we are going to create our Qt Program source code file
- Type/Copy/Paste: nano main.cpp
- or
- Type/Copy/Paste: gedit main.cpp
- This command will create the main.cpp file for the Qt program
- Now add the following lines in the code box below to your main.cpp source code file.
- Type/Copy/Paste:
#include #include #include int main(int argc, char *argv[ ]) { QApplication app(argc, argv); QLabel hello("Welcome to my first WikiHow Qt program"); hello.setWindowTitle("My First WikiHow Qt Program"); hello.resize(400, 400); hello.show(); return app.exec(); }
- Save the file as main.cpp and exit
- Make sure you are in the QtHelloWorld directory before you enter the following commands below to build and compile the file.
- Type/Copy/Paste: qmake -project
- This will create the Qt project file
- Type/Copy/Paste: qmake
- This will create the Qt make file
- Type/Copy/Paste: make
- This will compile the Qt make file on your system into an executable program. At this point, providing that there are no errors the file should compile into an executable program.
- Finally execute your program by running the Qt executable. Use the command ./ to run your executable file or type the name of the executable program on the terminal line.
- Type/Copy/Paste: ./QtHelloWorld
3.5 ★ | 2 Vote
You should read it
- How to Copy and Paste the Contents of a PDF File into a New File
- What is thermal paste?
- How to Set Default Programs in Windows 8
- How to copy and paste on Mac
- How to Make a Program Using Notepad
- AR Cut & Paste - Application 'cut' real life objects 'paste' into Photoshop file
- How to fix File Is Open in Another Program error
- How to Cut and Paste
- How to Open a BIN File
- Fixing errors cannot Copy Paste in Windows
- How to fix 'File Is Open in Another Program' in Windows 10
- How to Copy and Paste on Mac
Maybe you are interested
5 ways to quickly launch programs on Windows
10 tips to remove uninstallable programs
16 unnecessary Windows programs and applications you should uninstall
5 best programs to install on a new gaming PC
7 best laptop models for programmers
Huawei announced the 'Cangjie' programming language developed by the company