The Qt Software Development Kit (SDK) is a cross-platform application framework commonly used to develop application software with a graphical user interface (GUI). It is a portable cross-platform application framework for user interfaces that runs on Windows, Linux and Mac OS X operating systems. This program helps you create GUIs for your applications on these operating systems. Some popular cross-platform applications that have been used using the Qt SDK are KDE, Google Earth, Skype, Linux Multimedia Studio, and VLC Media Player. Multiplatform means in summary that the Qt applications you create on Windows via source code are usually transferable to Linux and Mac operating systems, and vice versa.
Steps
Method 1 of 6: Qt SDK 4.8 Installation Instructions
Step 1. In order to prepare the development environment for the Qt SDK we need to obtain the Qt SDK
Download the Qt SDK. Select the Windows version and be prepared for long download times according to your connection speed. If you don't have a very fast connection, offline installation is suggested. The full Qt SDK for Windows is 1.7GB, and downloading a file of this size can take more than 6 hours on a slow connection
Step 2. Install the Qt SDK by clicking on its executable
Once the program is installed, you will need to change the Windows system PATH so that the operating system can find the Qt commands from the command line. Be careful when changing the PATH.
Method 2 of 6: Change the PATH on Windows Vista / Windows 7
Step 1. Follow the steps below
- Click on Start.
- Click on "Control Panel".
- Click on System and Maintenance
- Click on System
- Click on Advanced System Settings
- Click on Environmental Variables
- Click on PATH to edit system variables
- Click OK when done
Method 3 of 6: Change the PATH on Windows 8
Step 1. Follow the steps below
- Click on the Folder icon located in the bottom bar next to the Internet Explorer icon
- Scroll to Computer
- Right click with the mouse on Properties
- Click on Advanced System Settings
- Click on Environmental Variables
- Click on PATH to edit system variables
- Click OK when done
Step 2. Add the following system PATH
-
Type / Copy / Paste:
; C: / QtSDK / mingw / bin; C: / QtSDK / Desktop / Qt / 4.8.1 / mingw / bin;
- This will set up Windows to compile Qt applications from the command line. The numbers 4.8.1 denote the SDK version number, which changes with each update, replace the new version number with your Qt SDK number.
Step 3. Important:
use the version of MinGW included in the SDK to build your Qt applications. If you have installed another version of the MinGW compiler on the PATH of your computer, such as; C: // MinGW / bin, you will need to remove it and add the Qt version of MinGW included in the SDK. This is very important if you have another version of the MinGW C / C ++ compiler installed on your Windows system, as it would cause conflicts. Basically, if you use another version of the MinGW C / C ++ compiler your Qt application that you create from the command line will not work and will end with multiple system error messages. You will need to use the compiler version included in the Qt SDK.
Step 4. Once the Qt SDK PATH has been added to the Windows operating system, to check if you are able to compile from the command line, open a command prompt and type the following command
Step 5. Type / Copy / Paste:
qmake -version
- You should get a response similar to this:
- ' QMake version 2.01a
- ' Using Qt version 4.8.1 in C: / QtSDK / Desktop / Qt / 4.8.1 / mingw / lib
Step 6. Develop your applications from the command line using a text editor such as Notepad or Wordpad to create and edit source code and compiling Qt applications from the command line
Step 7. You will be able to compile the applications using the following commands, which you enter in a command prompt
-
Type / Copy / Paste:
mkdir Qt-Applications
-
Type / Copy / Paste:
cd Qt-Applications
-
Type / Copy / Paste:
mkdir QtHelloWorld
-
Type / Copy / Paste:
cd QtHelloWorld
Step 8. When in the QtHelloWorld folder, use a text editor such as Notepad or Wordpad to create the Qt source code
Type the following code:
-
Type / Copy / Paste:
notepad main.cpp
- Make sure you save the Qt source code file as main.cpp
- or
-
Type / Copy / Paste:
start wordpad
- Using Wordpad as a text editor you will need to manually save the Qt source code as main.cpp
Step 9. Create the application in the text editor by typing the following code
Type / Copy / Paste:
#include #include #include #int main (int argc, char * argv ) {QApplication app (argc, argv); QLabel hello ("Welcome to my first Qt program"); hello.setWindowTitle ("My First Program Qt on Windows "); hello.resize (400, 400); hello.show (); return app.exec ();}
* Save the source code file as main.cpp * While in the QtHelloWorld folder, run the following commands to compile the code and link to it. * Type / Copy / Paste:
qmake -project ** This will create the Qt project file * Type / Copy / Paste:
qmake ** I prepared the Qt project for compilation * Type / Copy / Paste:
make ** You will compile the Qt source code into an executable program * After performing the above actions without errors, the Qt application will be created in the QtHelloWorld folder, as an executable with the extension .exe. Navigate to the folder path and run the Qt application by clicking on it or from the command line. * Type / Copy / Paste:
cd debug ** Go to the debug folder * Type / Copy / Paste:
QtCiaoMondo.exe ** Run the new executable you created * Congratulations you just compiled your Qt application from the Windows command line.
Method 4 of 6: Qt SDK 5.0 Installation Instructions
Step 1. In order to prepare the development environment for the Qt SDK we need to obtain the Qt SDK
Download the Qt SDK. Select the Windows version and be prepared for long download times according to your connection speed. If you don't have a very fast connection, offline installation is suggested. The full Qt SDK for Windows is 1.7GB, and downloading a file of this size can take more than 6 hours on a slow connection
Step 2. Install the Qt SDK by clicking on its executable
Once the program is installed, you will need to change the Windows system PATH so that the operating system can find the Qt commands from the command line. Be careful when changing the PATH.
Method 5 of 6: Change the PATH on Windows Vista / Windows 7
Step 1. Follow the steps below
- Click on Start.
- Click on "Control Panel".
- Click on System and Maintenance
- Click on System
- Click on Advanced System Settings
- Click on Environmental Variables
- Click on PATH to edit system variables
- Click OK when done
Method 6 of 6: Change the PATH on Windows 8
Step 1. Follow the steps below
- Click on the Folder icon located in the bottom bar next to the Internet Explorer icon
- Scroll to Computer
- Right click with the mouse on Properties
- Click on Advanced System Settings
- Click on Environmental Variables
- Click on PATH to edit system variables
- Click OK when done
Step 2. Add the following system PATH
-
Type / Copy / Paste:
; C: / Qt / Qt5.0.2 / 5.0.2 / mingw47_32 / bin; C: / Qt / Qt5.0.2 / Tools / MinGW / bin;
- This will set up Windows to compile Qt applications from the command line. The numbers 5.0.2 denote the SDK version number, which changes with each update, replace the new version number with your Qt SDK number.
Step 3. Important:
use the version of MinGW included in the SDK to build your Qt applications. If you have installed another version of the MinGW compiler on the PATH of your computer, such as; C: // MinGW / bin, you will need to remove it and add the Qt version of MinGW included in the SDK. This is very important if you have another version of the MinGW C / C ++ compiler installed on your Windows system, as it would cause conflicts. Basically, if you use another version of the MinGW C / C ++ compiler your Qt application that you create from the command line will not work and will end with multiple system error messages. You will need to use the compiler version included in the Qt SDK.
Step 4. Once the Qt SDK PATH has been added to the Windows operating system, to check if you are able to compile from the command line, open a command prompt and type the following command
Step 5. Type / Copy / Paste:
qmake -version
- You should receive a response similar to this:
- ' QMake version 2.01a
- ' Using Qt version 5.0.2 in C: / Qt / Qt5.0.2 / mingw / lib
Step 6. Develop your applications from the command line using a text editor such as Notepad or Wordpad to create and edit source code and compiling Qt applications from the command line
Step 7. You will be able to compile the applications using the following commands, which you enter in a command prompt
-
Type / Copy / Paste:
mkdir Qt-Applications
-
Type / Copy / Paste:
cd Qt-Applications
-
Type / Copy / Paste:
mkdir QtHelloWorld
-
Type / Copy / Paste:
cd QtHelloWorld
Step 8. When in the QtHelloWorld folder, use a text editor such as Notepad or Wordpad to create the Qt source code
Type the following code:
-
Type / Copy / Paste:
notepad main.cpp
- Make sure you save the Qt source code file as main.cpp
- or
-
Type / Copy / Paste:
start wordpad
- Using Wordpad as a text editor you will need to manually save the Qt source code as main.cpp
Step 9. Create the application in the text editor by typing the following code
Type / Copy / Paste:
#include #include #include #int main (int argc, char * argv ) {QApplication app (argc, argv); QLabel hello ("Welcome to my first Qt program"); hello.setWindowTitle ("My First Qt Program on Windows"); hello.resize (400, 400); hello.show (); return app.exec (); }
- Save the source code file as main.cpp
- While in the QtHelloWorld folder, run the following commands to compile the code and link to it.
-
Type / Copy / Paste:
qmake -project
This will create the Qt project file
- With the Qt 5.0 SDK you will need to use a text editor and add the following commands to the *.pro file you generated.
-
Type / Copy / Paste:
notepad QtHelloWorld.pro
- The QtHelloWorld.pro file you generated should look something like this:
TEMPLATE = app TARGET = QtHelloWorld #INCLUDEPATH + =. # Input SOURCES + = main.cpp
Edit the QtHelloWorld file like this:
TEMPLATE = app TARGET = QtHelloWorld QT + = core gui QT + = widgets #INCLUDEPATH + =. # Input SOURCES + = main.cpp
- Once the above lines have been added to the QtHelloWorld.pro file under the TARGET keyword, then run qmake
-
Type / Copy / Paste:
QT + = core gui
-
Type / Copy / Paste:
QT + = widgets
Save the file and exit
-
Type / Copy / Paste:
qmake
This will create the Qt make
-
Type / Copy / Paste:
make
You will compile the Qt make file on your system into an executable program. At this point, if you haven't made any mistakes, the file should be compiled
- After performing the above actions without errors, the Qt application will be created in the QtCiaoMondo folder, as an executable with the extension .exe. Navigate to the folder path and run the Qt application by clicking on it or from the command line.
-
Type / Copy / Paste:
cd release
Navigate to the destination folder path
-
Type / Copy / Paste:
QtHelloWorld.exe
Run the new executable you created
- Congratulations you just compiled your Qt application from the Windows command line.