Questions & Answers from Qt for Beginners Part 1

Questions & Answers from Qt for Beginners Part 1 - Overview and Key Concepts

By Jeff Tranter

Download the entire webinar series.

What is Qt's take on T2S applications?

Assuming this refers to TARGET2-Securities, the European securities settlement engine, I don't know of anything relevant in Qt except possibly the Qt Purchasing API which supports In-App Purchases, but could potentially support other financial features in the future.
 

Does the += mean to add to the existing variable definition?

In the context of the QString class, the += operator is overloaded to perform string concatenation. Several other classes also overload this operator. See the Qt documentation under operator+= for details.

 

In Qt Quick how do you place the rectangle on the screen?

Typically a QML view is created and made visible in C++ code which then loads one or more QML files. Our upcoming QML webinar will cover this in more detail.
 

Will unit testing be covered at some point in the series?

We covered this in a previous webinar which you can view on demand. See https://www.ics.com/webinars/qt-test-framework There is also a follow-up webinar available on "Qt Test Driven Development using Google Test and Google Mock" that you may find relevant.
 

How "mature" is Qt for iOS development?

I don't have direct experience with it, but my impression is that it is less mature than the Android version, but people have successfully developed iOS applications and had them accepted in the Apple store. You may need the commercial version of Qt in order to meet Apple's requirements for applications in its store.

 

About the memory management of QObject-derived classes, do we have to assign a parent for objects created on heap?

You have to pass a pointer to a parent in the constructor, but it can be a null pointer in the case where there is no parent object.

 

So the last 3 are only available to Qt5? (This is referring to slide 56).

Yes, and only on platforms where the C++ compiler has suitable C++11 support.

 

What support does Qt have for DPI-independent rendering on displays?

Qt recently (in Qt 5.6) added support for High DPI Displays. See the Qt documentation under "High DPI Displays".
 

You mentioned eBooks' for Qt 5.x... could you give any references to them?

See https://wiki.qt.io/Books for a list of print and eBooks.
 

Is there a way that CONNECTION is checked at compile time for matching SIGNAL and SLOT?

With the "traditional" connect format (the first example on slide 56) Qt does not check that the signals and slots are valid at compile time. The other three examples do provide checking at compile time.

 

If you're writing an application for both iOS and Windows desktop, would you recommend Qt Quick or Widgets?

Hard to say - it depends on the look and feel of your application. You may find that you need different user interfaces on each platform. If your desktop is Windows 10, possibly with a touchscreen, Qt Quick may be a good fit for both platforms.
 

What is the advantage of using properties vs setters and getters?

They actually work together. Properties use setters and getters but makes them explicit and exposes them to the Meta information about the class.
 

In the previous slide it had hello.show() , referring to the button object? It isn't app.show()?

No, making the widget visible is correct. The app (a QApplication) is not a visible object.
 

Is Qt creator completely free? Is there a windows version?

Yes, it is free in the sense of being open source. You can download a Windows version from https://www.qt.io/download/
 

You didn't mention PyQt, what's your opinion of PyQt?

PyQt are bindings for Qt for the Python language. I like it. It has some pros and cons as compared to using C++. We plan to cover this in a future webinar.
 

What is the most used IDE in Linux environments except the creator?

Probably Microsoft Visual Studio with the Qt plugin, and X-Code on Mac OS X. There used to be support for Eclipse but I think that is no longer maintained.

 

I have some applications written in Scilab language and would like to turn them into executable using Qt. Is it a good idea?

I have not used Scilab, but we have used similar tools like MATLAB and integrated it into a Qt application. I'd need to understand more about Scilab and how you were using it to evaluate how hard it would be to do this.

 

When would I choose Qt C++ over Qt Quick or vice-versa?

Generally there will be some C++ code even when using QML. QML is a good fit for the graphical/visual part of an application, with C++ for the business logic and anything that is CPU intensive.

 

What is difference between QtQuick Control vs. QtQuick Control2?

The original Qt Quick controls are aimed at desktop use, to run on the desktop platforms and replace widgets. The new Qt Quick Controls 2 or Qt Labs controls are lighter weight and better suited for use on embedded platforms.
 

What is the latest and greatest Qt text book?

Unfortunately most of the printed books refer to older versions of Qt. See https://wiki.qt.io/Books for a list of print and eBooks.

 

Do you set x,y for a rectangle?

You can, but you typically use layouts for this rather than specifying specific coordinates. We'll cover this in the upcoming QML webinar.
 

Can a single build system utilize qmake to multiple versions from a single machine? For example, we have a Windows system where we build our Qt application and produce a windows version. Can we use the same box to produce a Mac version or does it have to be compiled on a Mac system?

You can if the compiler is supported on that machine and platform. In many cases that is not true. You can use virtual machines running on the same hardware with different operating systems to allow you to build for Linux, Windows, Mac, etc. Tools like Jenkins can be useful for automating builds for multiple platforms.
 

Qt for iOS? Is anyone using it for iPhone and iPad?

Yes, Qt is supported on iOS for iPhones and iPads. It is perhaps not as mature on this platform as on some others, but people have successfully developed apps and released them to the Apple store.
 

What are your thoughts about the future of Qt?

It is hard to give a short answer. I think Qt is healthy and has a bright future. It will probably follow industry trends, as it has when mobile devices became popular, and more recently embedded systems with touchscreens and powerful CPUs and GPUs. As new technologies become popular, Qt will likely add support for them (support for speech recognition and generation is coming in Qt 5.7, for example). It looks like Qt will also expand into lower level functions, as evidenced by the recent support added for Modbus, CAN bus, and Bluetooth Low Energy.

 

Do you see the newer C++ features obsoleting anything in Qt like MOC?

There has been some discussion of this, and there is an interesting fork of Qt called CopperSpice that replaces MOC. I think this is unlikely to happen, certainly not before Qt 6, because it would probably break binary compatibility. I do expect to see some features of Qt to be deprecated because C++ provides equivalent features. This has happened for algorithms for containers and could happen for threading, for example. The foreach keyword I mentioned for iterating over containers can now be done with a for loop in C++11.
 

I come from Qt 4.x and I'd like to update my knowledge to Qt 5.x, are there any summaries?

Yes. See some of the documentation here: http://doc.qt.io/qt-5/portingguide.html
 

Which online courses can you recommend?

I'm not familiar with any on-line courses that I can recommend. Reading the Qt documentation and tutorials and doing hands-on programming would be my recommendation. If you can find an experienced person to mentor you, that can help when you run into problems (or make use of the Qt forums and mailing lists).
 

What compositor back ends are supported? X11 on Unix/Linux, I suppose. Wayland/Weston? How about on embedded devices? Would I use direct frame buffer there?

Some of the common back ends on Linux and embedded platforms are OpenGL/ES, the Linux frame buffer, Wayland, and xcb (X11). To use QML you need support for OpenGL, so the most commonly used back end on embedded platforms is OpenGL/ES (the eglfs back end). DirectFB is another option but its future is uncertain as no one seems to be maintaining it (not the Qt back end, but DirectFB itself).
 

The version numbering seems a little confusing: QtQuick 2.6 corresponds to Qt 5.6? Is that true for all releases that the major number of Qt Quick is 3 less than the major number of Qt?

Each Qt module has a version number and they don't always match the Qt release version number. QtQuick 2.6 does correspond to the latest version in Qt 5.6. Right now it is just a number that is increment each time the module has API changes, but won't necessarily change with each Qt release. There has been some discussion about making the versions the same as the Qt version number.

 

What is the latest version for the Qt open source? And where we can get a download?

 

Any recommendations which IDE to use under Linux except QtCreator?

The only other Qt IDE I have used under Linux is KDevelop. I have used Eclipse in the past but I don't believe it supports Qt anymore. There are some others, but I don't have personal experience with them.