Overview:
QtSampler is a simple Qt application that serves as a starting point for developers looking to build graphical user interface (GUI) applications using the Qt framework. It provides a basic structure and functionality to help you understand how to create Qt-based projects.
Features:
- Minimalistic GUI application.
- Utilizes Qt Widgets for the graphical interface.
- Written in C++ for flexibility and performance.
- Easy-to-understand code structure for educational purposes.
Before you begin, ensure you have met the following requirements:
-
C++ Compiler:
- Your preferred C++ compiler (e.g., GCC, Clang).
-
Qt Framework:
- Version 5.12.8 or higher.
- Modules: Widgets, Core, Gui.
-
Build System:
- qmake (typically included with Qt).
-
Operating System:
- Linux (Ubuntu)
This project relies on the Qt framework. Follow the steps below to install Qt:
-
Download Qt: Visit the official Qt download page and download the installer for your platform.
-
Install Qt: Run the downloaded installer and follow the installation instructions. Make sure to select the necessary components, including the Qt version, modules (e.g., Qt Widgets), and tools.
-
Set up Qt Paths: After installation, add the Qt bin directory to your system PATH. For example, on Linux, add the following line to your shell profile file (e.g.,
~/.bashrc
or~/.zshrc
):export PATH="/path/to/qt/bin:$PATH"
On Ubuntu or other Debian-based Linux distributions, use the following command to install the Qt 5 framework:
sudo apt update
sudo apt install qt5-default
This command installs the default version of the Qt framework (Qt 5) along with essential development tools.
Verify the Installation:
After the installation, you can verify that Qt is installed correctly by checking the installed version:
qmake --version
This should display information about the installed version of qmake, the build date, and the Qt version.
For example:
QMake version 3.1
Using Qt version 5.12.8 in /usr/lib/x86_64-linux-gnu
Inside the .vscode
folder, in c_cpp_properties.json
file, make sure to modify "compilerPath" value to point to the location of your GCC compiler, if your GCC location is different.
Also, make sure to modify "includePath" value to point to the location of your Qt library if you have a different version of Qt or a different directory structure (other than /usr/include/x86_64-linux-gnu/qt5
).
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/x86_64-linux-gnu/qt5/QtWidgets",
"/usr/include/x86_64-linux-gnu/qt5"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
Follow these steps to build the project:
Clone the Repository:
git clone https://github.com/babak2/QtSampler.git
cd QtSampler
If you have the version of Qt and the same directory structure (/usr/include/x86_64-linux-gnu/qt5
), you can use the provided Makefile and build the project using:
make
If successful, the executable (e.g., QtSampler) should be generated in the project directory.
If you have a different version of Qt or a different directory structure (other than /usr/include/x86_64-linux-gnu/qt5
), use QtSampler.pro and run the following command to generate the Makefile:
qmake -o Makefile QtSampler.pro
Build the project using:
make
Execute the compiled binary:
./QtSampler
This program is licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE for more information.
Babak Mahdavi Ardestani