No matter what platform you are installing Qt Creator on, the amount of disk space required can be very large, depending on the selected “kits”.
On Debian-like machines (e.g. Ubuntu):
You need at least the Xcode command line tools installed so that Qt Creator can find/use the C++ compiler.
You can download both Xcode and the Xcode command-line tools from the Apple app store.
The Xcode command-line tools can be installed with:
Available Qt Kits For macOS:
- Desktop Qt x.x.x clang 64bit
Qt will typically install into your user directory, including a directory for both the version of Qt and the kit used. For example, using
v5.13.0 and the Clang 64-bit kit, the default install path would look something like
- MSVC2017 64-bit
Qt is designed around an event/listener paradigm (which they call signals and slots) which promotes an event driven design over blocking method calls.
All UI interaction must occur in one thread (the default UI thread). It is not advisable to add blocking calls in this thread as this will make the UI unresponsive while the thread is blocked.
Allowing File Names With Capital Letters
It seems a little strange, that by default, Qt Creator will not allow files with capital letters in them. This was probably done to prevent problems when using FAT32 file systems (e.g. older versions of Windows) that were case insensitive (yet case preserving). However, many common file naming standards for C++ along with many 3rd party libraries will use capital letters. Luckily, you can enable/allow capital letters in file names in the Qt Creator settings:
Click Tools from the top menu bar and then click on Options.
Uncheck the Lower case file names checkbox.
Serial Port (QSerialPort)
Qt allows you to access serial ports on the machine via the
QSerialPort class. Note that serial port operations such as reading and writing must be done from the same thread. In that respect, if you do need to do both reading and writing, it is best not to use a blocking approach for reading, as you can not both block on a read call and send data at the same time. The better alternative is to use the readyRead signal
Compatibility With std Library
Qt Threads and std::condition_variable
In my experience,
std::condition_variable seems to work without any issues when within a Qt thread.
Unused Parameter ‘xxx’
Qt can provide warnings when function parameters are unused. This can be a good thing, however it can be annoying and clutter up the compile output when you are purposely ignoring function parameters.
To remove this warning, you can either delete the name of the unused parameter from the function definition:
Or use the
Connecting Signals And Slots
Prior to Qt5, you have to use the
SLOT() macros in the call to
Qt5 introduced a new syntax for connecting signals to slots:
This new syntax for
connect() has the following benefits:
- Will produce compile errors if the signal/slot does not exist (this is a VERY good advantage)
- Will produce compile errors if the types do not match (another good pro!)
- Input parameters do not need to be specified (although this does have its drawbacks when the signal or slot is overloaded, see below)
I recommend the new Qt5 syntax wherever possible!
However, this syntax won’t work if there is more than one signal with the same name (i.e. an overloaded signal). An example of this would be the
QComboBox::activated() signal, which has the following two overloads:
If you were trying to connect the
activated(int index) signal to your custom handler, this you would have to do the following:
QWidget GUI Layout
GUI layout in Qt is done with both
QLayout objects. The GUI is based upon a hierarchy of
Qwidget objects can have multiple
QWidget’s as children elements. You can create and assign a
QLayout object to a
QWidget object (using
my_widget->setLayout()), and then the
QLayout object will control the layout of the
QLayoutobjects cannot be assigned as children of a
QWidgetobjects are the only objects allowed in the GUI hierarchy tree, each
QLayoutmust be assigned to a
All GUI elements in a standard Qt GUI application inherit from the base class
You do not have to manually delete
QWidget objects that you have created, as long as they have a
QWidget parent which will be deleted.
QScrollArea inherits from
QWidget and provides a block UI element which allows the user to scroll when the child widget(s) exceed the
QScrollArea::setWidgetResizeable() gives the scroll area permission to resize it’s child widgets. This means that
child_widget.resize() may not have any effect.
Watching For Text Changes
What is an app bundle?
CICD services which support macOS? Azure does support macOS workers for building/deploying your application. TravisCI currently does not.
The open-source program
linuxdeployqt (available from here aims to mimic the functionality of
macdeployqt, but for Linux instead of macOS. It aims to bundle all dependencies together to produce a single file that is executable.
The Qt installation includes an executable called
macdeployqt (located at
<Qt install dir>/bin/). This command-line program can be used to create a disk image (
.dmg) file from the app bundle.
To create a
This work is licensed under a Creative Commons Attribution 4.0 International License .
- Magic Statics
- Python SWIG Bindings From C/C++
- Consistent Overhead Byte Stuffing (COBS)
- A Tutorial On geopandas