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
15
votes
2 answers

Is there a way to distinguish between programmatic index changes and user selection index changes?

I have a QComboBox. I have two use cases. In one use case, the combo box is programmatically changed to have a new index via setCurrentIndex(). In the other use case, the user clicks and selects a new combo box selection with the mouse. Both of…
user2836797
15
votes
2 answers

New drag-and-drop mechanism does not work as expected in Qt-Quick (Qt 5.3)

I've tried to implement drag and drop in Qt 5.3 using the new QML types Drag, DragEvent and DropArea. This is the original example from the documentation of the QML Drag type with some small modifications: import QtQuick 2.2 Item { width: 800;…
isnot2bad
  • 24,105
  • 2
  • 29
  • 50
15
votes
4 answers

Closing a QMainWindow on startup?

I have a Qt application that uses a QMainWindow-derived class for the main UI. On startup I want to make some security checks and, if they fail, display a message to the user and close the main window. Currently I make these checks in the…
Rob
  • 76,700
  • 56
  • 158
  • 197
15
votes
2 answers

What is jom in qt build system ? how to call jom from command line to build qt project?

Trying to build and run a simple "Hello world.." Qt application from command line, started the following steps and struck in compiling and building.. 1. created main.cpp file 2. run qmake -pro to create project file 3. run qmake to create make…
Prady
  • 663
  • 3
  • 11
  • 28
15
votes
3 answers

How to add style via setStyleSheet() without losing the original style(s) in Qt?

I know I can use setStyleSheet() to set styles in Qt. But when I use setStyleSheet() twice, the first styles are lost, which are set by first use of setStyleSheet(). For…
waterd
  • 603
  • 1
  • 7
  • 23
15
votes
4 answers

How to generate .sln/.vcproj using qmake

I have main.cpp in c:\test folder and do the following: qmake -project qmake -tp vc test.pro The answer is: WARNING: Unable to generate output for: C:/test//Makefile.Debug [TEMPLATE vcapp] WARNING: Unable to generate output for:…
stas
  • 631
  • 2
  • 7
  • 9
15
votes
5 answers

How do you debug Qt layout problems

I've got a complex dialog, and it is full of whitespace and I can't shrink it. In Designer, it has lots of components that then get dynamically hidden, and a few which are dynamically added. I've added dumping of size policies, size hints, and…
Mike Elkins
  • 1,408
  • 1
  • 11
  • 12
15
votes
1 answer

Using SQLite with Qt

I am thinking of using SQLite as a backend DB for a C++ applicatiojn I am writing. I have read the relevant docs on both teh trolltech site and sqlite, but the information seems a little disjointed, there is no simple snippet that shows a complete…
Stick it to THE MAN
  • 5,621
  • 17
  • 77
  • 93
15
votes
2 answers

How to get human-readable event type from QEvent?

I want to debug event handling code and would like to convert QEvent::Type enum's value to a human-readable string. QEvent has a Q_GADGET macro, so presumably there's a way of pulling that off?
Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
15
votes
2 answers

How to change the text color of items in a QListWidget?

I want to change the text color of the items in QListWidget. For example, some items are in red text while others are in blue text. How do I do that? Thank you.
Jimmie
  • 359
  • 2
  • 4
  • 9
15
votes
1 answer

When, where and why use namespace when registering custom types for Qt

Similar questions have been raised multiple times, but I'm focussing on the namespace and pointer issues. MyClass.h namespace foo { class MyClass { MyClass(); }; QDataStream &operator<<(QDataStream &out, const MyClass & myObj); QDataStream…
braggPeaks
  • 1,158
  • 10
  • 23
15
votes
1 answer

frameless windows with qt5 (qml)

I spent some good hours on web searching but nothing help me.. I build GUI with QML and I want him without frame. I tried to change my main.cpp like this: #include #include "qtquick2applicationviewer.h" int main(int argc,…
AsfK
  • 3,328
  • 4
  • 36
  • 73
15
votes
1 answer

How to print a QQuickView's contents to PDF?

I'm upgrading some Qt (C++ & QML) code from Qt4.8 to Qt5.1. The Qt4.8 code is a trivial C++ "QML viewer" app subclassing a QDeclarativeView, and a bunch of QML. It's been easy enough to change this to use Qt5/QtQuick2's QQuickView except for one…
timday
  • 24,582
  • 12
  • 83
  • 135
15
votes
5 answers

How can I avoid creating a property binding on initialization in QML?

I want to create a custom QML component with two properties one and two, which should have default values when left uninitialized. In particular, if two should get an initial value depeding on one. The following code Rectangle { property int one:…
Tobias
  • 6,388
  • 4
  • 39
  • 64
15
votes
2 answers

QFileDialog: adding extension automatically when saving file?

When using a QFileDialog to save a file and to specify the extension (like *.pdf) and the user types in a name without this extension, also the saved file hasn't this extension. Example-Code: QFileDialog fileDialog(this, "Choose file to…
Berschi
  • 2,605
  • 8
  • 36
  • 51