Questions tagged [qt]

Qt is a cross-platform application development framework widely used for the development of application software that can be run on various software and hardware platforms with little or no change in the underlying codebase, while having the power and speed of native applications. Qt is available with both commercial and open source licenses.

General information

Official logo

Qt logo

About

Qt (pronounced officially as cute (/'kjuːt/) though commonly pronounced as Q.T. (/ˈkjuː.tiː/)) is a cross-platform application development framework widely used for the development of GUI programs (where it functions like a cross-platform widget toolkit), and also used for developing non-GUI programs such as console tools and servers. wikipedia

Qt was created by Trolltech, and was acquired by Nokia in 2008. One month after the end of symbian development at Nokia, Nokia decided to sell Qt. From September 2012 and until now Qt is managed by the Qt Company which is subsidiary of Digia.

License

Qt is available under four different licenses:

  1. GNU General Public License (GPL) version 3.0
  2. GNU Lesser General Public License (LGPL) version 2.1
  3. GNU Lesser General Public License (LGPL) version 3.0
  4. Qt Commercial License (which comes in three versions with different features and prices: "Indie Mobile", "Professional" and "Enterprise")

Current version

The latest official release is 5.14. The major version indicates API and binary compatibility.

Recommendations

Tagging

You will often see questions tagged specifically as , , or to indicate that the question is related to Qt 3.x, 4.x, 5.x or 6.x respectively. Qt 3.x is no longer supported, and Qt 6 is still in beta. The latest released major version is still Qt 5.x so, when not specifically mentioned, version 5.x of the API should be assumed.

Spelling

The correct spelling is Qt, not to be confused with QT, which stands for QuickTime - an extensible multimedia framework developed by Apple Inc.

Reminder

Please, do not answer poor questions that will likely get closed or even deleted later. We are aiming for high-quality in this tag, thus we do not wish to encourage poor questions by feeding them with answers.

Resources

Documentation

There is an extensive official documentation (all classes) available on Qt's website, in addition to tutorials and examples. You will often see these tutorials and examples referenced in the questions and answers on this site. Qt also provides an integrated development environment, IDE, named Qt Creator. Although it mainly aims at creating Qt applications, it can be used to create regular C++ applications as well.

Video courses

Pluralsight has a series of three courses on Qt:

  1. Introduction to Qt: A C++ Cross Platform Application Framework
  2. Qt Quick Fundamentals
  3. Integrating Qt Quick and C++

Pluralsight is a subscription based but if you're only interested in Qt you can send the author @todgentille a private tweet and request a week long VIP pass. You'll get unlimited access to the higher subscription level for a week that allows viewing online and offline and you can download the course materials.

Packtpub also has a video tutorial based on Qt 5.

Voidrealm released a full free series of Qt tutorials for beginners on his youtube channel.

Books

Qt introductory books:

Integrated learning of Qt and C++:

Concepts of UI design:

Please, check out the official Qt documentation for more details of recommended books about Qt programming.

79389 questions
102
votes
2 answers

Qt c++ aggregate 'std::stringstream ss' has incomplete type and cannot be defined

I have this function in my program that converts integers to strings: QString Stats_Manager::convertInt(int num) { stringstream ss; ss << num; return ss.str(); } But when ever i run this i get the…
tyty5949
  • 1,310
  • 5
  • 12
  • 16
101
votes
2 answers

Does Qt support virtual pure slots?

My GUI project in Qt has a lot of "configuration pages" classes which all inherit directly from QWidget. Recently, I realized that all these classes share 2 commons slots (loadSettings() and saveSettings()). Regarding this, I have two…
ereOn
  • 48,328
  • 33
  • 147
  • 228
100
votes
6 answers

Convert an int to a QString with zero padding (leading zeroes)

I want to "stringify" a number and add zero-padding, like how printf("%05d") would add leading zeros if the number is less than 5 digits.
elcuco
  • 8,321
  • 9
  • 42
  • 63
100
votes
3 answers

Using emit vs calling a signal as if it's a regular function in Qt

Let's say I have this signal: signals: void progressNotification(int progress); I only recently learned about the emit keyword in Qt. Until now, I used to execute signals by just calling them like a regular function. So instead of: emit…
sashoalm
  • 63,456
  • 96
  • 348
  • 677
98
votes
4 answers

Memory management in Qt?

I'm quite new to Qt and am wondering on some basic stuff with memory management and the life of objects. When do I need to delete and/or destroy my objects? Is any of this handled automatically? In the example below, which of the objects I create…
Martin
  • 2,039
  • 2
  • 18
  • 10
98
votes
2 answers

undefined reference to template function

I have three files . The contents of main.cpp are #include #include #include "util.h" int main() { using Util::convert2QString; using namespace std; int n =22; QString tmp = convert2QString(n); return…
Vihaan Verma
  • 11,446
  • 17
  • 84
  • 120
93
votes
4 answers

what does __declspec(dllimport) really mean?

I saw the Qt source code like this: class Q_CORE_EXPORT QBasicAtomicInt { public: ... }; Which Q_CORE_EXPORT macro defines like below: define Q_DECL_IMPORT __declspec(dllimport) So what does __declspec(dllimport) really mean?
gemfield
  • 2,852
  • 5
  • 21
  • 24
93
votes
7 answers

How to build a full path string (safely) from separate strings?

Does C++ have any equivalent to python's function os.path.join? Basically, I'm looking for something that combines two (or more) parts of a file path so that you don't have to worry about making sure the two parts fit together perfectly. If it's in…
sas4740
  • 3,480
  • 6
  • 21
  • 22
91
votes
9 answers

What should I choose: GTK+ or Qt?

Can someone suggest what's the best uses for those libraries today? Is it just GUI, or do they have database, XML, networking, threading, etc support too? I was reading about them, and considered starting to learning/using one of them. What is the…
Idan
  • 5,487
  • 9
  • 45
  • 82
90
votes
3 answers

Qt: *.pro vs *.pri

What is the difference between *.pro and *.pri configuration files for qmake? What should go into a *.pro file and what should go into a *.pri file?
Roman Byshko
  • 7,565
  • 5
  • 32
  • 54
88
votes
6 answers

How to redirect qDebug, qWarning, qCritical etc output?

I'm using a lot of qDebug() << statements for debug output. Is there any cross-platform way I can redirect that debug output to a file, without resorting to shell scripts? I'm guessing that open() and dup2() will do the job in Linux, but will it…
Septagram
  • 8,480
  • 11
  • 46
  • 76
88
votes
5 answers

What is the difference between QImage and QPixmap?

I do not understand what is the difference between QImage and QPixmap, they seem to offer the same functionality. When should I use a QImage and when should I use a QPixmap?
Mr.Tu
  • 2,245
  • 6
  • 27
  • 43
87
votes
8 answers

How to set image on QPushButton?

I want to set an image on QPushButton, and the size of QPushButton should depend on the size of the image. I am able to do this when using QLabel, but not with QPushButton. So, if anyone has a solution, then please help me out.
greshi Gupta
  • 1,001
  • 2
  • 8
  • 6
87
votes
13 answers

How can I get the selected VALUE out of a QCombobox?

In Qt, I can get the selected text of a QComboBox by using the combobox->currentText() method. How can I get the selected value? I searched for help but I couldn't find a method currentData() which I expected to find. I could only find…
sabbour
  • 4,730
  • 4
  • 32
  • 33
86
votes
6 answers

Set QLineEdit to accept only numbers

I have a QLineEdit where the user should input only numbers. So is there a numbers-only setting for QLineEdit?
sashoalm
  • 63,456
  • 96
  • 348
  • 677