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 6.2, released in September 2021. 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. The latest released major version is Qt 6.x so, when not specifically mentioned, version 6.x of the API should be assumed for questions posted after September, 2021.

Spelling

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

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:

Check out the official Qt documentation for more details of recommended books about Qt programming.

85593 questions
113
votes
11 answers

How to create a subdirectory for a project QtCreator?

I would like to divide my Qt project into several directories because it is growing pretty large. However, when I click on browse in QtCreator, there is no 'Add directory' and no such thing in 'Add new'. Can this be done somehow?
gruszczy
  • 40,948
  • 31
  • 128
  • 181
112
votes
8 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
  • 4,510
  • 8
  • 26
  • 23
112
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,948
  • 9
  • 47
  • 69
110
votes
6 answers

Why Qt is misusing model/view terminology?

I think that the terminology used in Qt with model/view controls is flawed. On their explanation page they state, that they simplified the MVC to MV by merging View and Controller and they are giving the following picture: However I think, they…
gorn
  • 5,042
  • 7
  • 31
  • 46
109
votes
3 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
  • 53,676
  • 39
  • 161
  • 238
108
votes
10 answers

Qt events and signal/slots

In the Qt world, what is the difference of events and signal/slots? Does one replace the other? Are events an abstraction of signal/slots?
Raphael
  • 7,972
  • 14
  • 62
  • 83
107
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
  • 3,228
  • 7
  • 27
  • 28
106
votes
5 answers

Qt Quick vs. Qt Widget

I am new to Qt and don't quite understand the difference between a Qt Quick Project and a Qt Widget Project. I am hoping to create a program that draws a lattice of hexagons that the user can rotate and shear, as well as pan around and zoom in and…
Anthony
  • 8,570
  • 3
  • 38
  • 46
105
votes
7 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
  • 9,425
  • 13
  • 50
  • 81
105
votes
9 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,191
  • 3
  • 8
  • 6
104
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,717
  • 10
  • 47
  • 84
103
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
  • 8,591
  • 7
  • 35
  • 57
103
votes
9 answers

How can I hide/delete the "?" help button on the "title bar" of a Qt Dialog?

I am using Qt Dialogs in one of my application. I need to hide/delete the help button. But i am not able to locate where exactly I get the handle to his help button. Not sure if its a particular flag on the Qt window.
AMM
  • 17,130
  • 24
  • 65
  • 77
103
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,269
  • 3
  • 19
  • 10
102
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
  • 75,001
  • 122
  • 434
  • 781