Apt Get Qt Update The Available
Qtbase5-examples contains the Qt Base 5 examples and qtbase5-doc-html Contains the HTML documentation for the Qt 5 base libraries. This can be done by typing in the terminal: sudo apt-get install qt5-doc qtbase5-examples qtbase5-doc-htmlThe package qt5-doc Contains the Qt 5 API documentation. To proceed with the installation, we open a terminal (Ctrl + Alt + T) and first we will update the available software and then install the package by typing:If you want Qt 5 to be used as the default Qt Creator version, then run the following command: sudo apt-get install qt5-default Please enter Y when the system prompts you with a choice to continue the installation.Sudo apt update sudo apt install build-essentialIf you don't have the Qt Creator package installed that contains the UI and command line tools for creating and running the Qt project, write in the same terminal:If you want Qt 5 to be used as the default version of Qt Creator, run the following command:To implement more complex projects, you will have to install Qt documentation and samples.
In the terminal (Ctrl + Alt + T) we write:Mkdir ProyectoQt Create a. The steps to follow are: Create a project directoryWe will start by creating a working directory for host our Qt project. Writing and compiling Qt programs from the Ubuntu command line is pretty straightforward.
Settings in the Qt project fileSince we want to compile the project from the command line, we will have to add the following line to the. This project file is the basic skeleton for Qt projects and can be edited. Create the Qt project fileAfter saving the file and inside the project folder, the following command will have to be executed to create a Qt project file: qmake -projectWe can verify that the previous command has created a file with the name of ProjectQt.pro in the project directory. Its only purpose is to print a line in a window with the title ' My first Qt program'.Hola.setWindowTitle("Mi primer programa Qt") Once pasted into the file, it only remains to save and close the editor. Cpp file: vim mainEjemplo.cppIn the blank file, just copy the following code.
/ProyectoQtThe output of this example is as follows:This is the basics that any user should know to write, compile, and run a first Qt program. You can launch the program by typing in the terminal, inside the project folder. Test the programIf you have reached this point, you are all set to launch the executable file that we created in the previous step. Qmake ProyectoQt.proNow, we will use make to compile the Makefile in an executable program: makeAs long as there are no errors in the project, this command should create an executable program in the working directory.The file ProjectQt in green color, it is the executable file Qt. QT += gui widgetsTo do this, there is only open the SampleProject.pro file and paste inside the previous line:Vim ProyectoQt.pro Create an executable file for the projectThe following command will create a file with the name of ' makefile' in the project directory.
For more information, consult the official Qt documentation.