The content of the cycle review speeches CppCon 2017:
Review of the performance of Lars Knoll, technical director of Qt Company. Do not expect too much from this performance. In square brackets italics are my notes.
Thanks for the opportunity to talk a bit about Qt. This is a C ++ framework. Its principles and philosophy are slightly different from those familiar to you in the standard library. [ Question to the audience ] Just for information, how many of you know Qt and used it before? Wow Thank you, great! It's fantastic! Then I will talk about things that you probably already know.
Perhaps this is the most comprehensive C ++ framework. But this is not only a framework, it is also a variety of tools that help develop embedded devices, Qt Quick's UI technology, not related to C ++, but integrated with it.
Two licenses: commercial and LGPLv3 / GPLv3. This is an open project.
Two products:
At the core are the integral libraries. The most important is Core, which contains main classes, I / O, work with files, etc. GUI library - the basis of the graphical interface. And many others.
Cross-platform development environment for desktop, mobile and embedded systems. Many people use it to program in pure C ++, without Qt. Supports the integration of various tools (profilers, debuggers ...), autocompiles, VCS ...
Early error detection with Qt Creator and CLang static analyzer
Fast forward to 26 years ago. Students Haarvard Nord and Eirik Chambe-Eng are thinking about a new project. At that time, they were developing GUIs for a system that ran on Unix, Macintosh, and Windows. That was hard. In the summer of 1990, they decided that they needed an object-oriented display system.
In 1993, the first graphics core was developed.
This version was called Quasar. Then there were no namespaces. Motif (a library of interface elements and a set of specifications for developing graphical interfaces under the X Window System) had its prefix. Therefore, the prefix "Q" was added, which played the role of the namespace. Now from that version much remained. That left the QObject - the central part that implements the signals / slots mechanism. And also QEvent, QFont, QPainter, QColor.
In 1994, they persuaded their wives to support them financially for a couple of years, and founded the company Trolltech.
Early version of the site Trolltech
The project was still pretty raw. In addition, sales of software via the Internet in those days were not popular, preferred by physical media. Accordingly, there was little money.
Worked completely without templates. Therefore, there were several specialized lists for pointers, integers, etc. Windows 95 / NT and UNIX / X11 were supported. The UNIX version was open source, since the small company needed to somehow distribute its product.
In 1997, Mattias Ettrich (known for his contribution to the KDE project) decided to use Qt to create KDE. This was probably the reason why Qt "took off."
It was released under the GPL license. Unicode support has been added. The project was granted venture capital. The number of employees for the year increased from 5 to 50.
Basic widgets were developed, as well as layers that provide a “flexible” interface. But people did not want to write code for this. Then Qt Designer appeared.
first version
At this time I went to work in Trolltech [ And therefore the author began to use the pronoun "we" further ]
We have replaced explicit sharing with implicit sharing for strings. People got a bunch of problems with strings. Then we decided to leave implicit sharing, but to create a new internal copy when the string changes (copy-on-write) [ more detailed ].
Began to use more templates, C ++ 98. A qobject_cast <> appeared (an analogue of dynamic_cast for a QObject, but not using RTTI). Open source for Mac.
Carefully reviewed the template and auxiliary classes. Moving from storing pointers to values ​​in containers to storing the values ​​themselves. Implicit sharing containers began to use atomic reference counting. Open source for Windows. For Windows, this was done last, because we needed income and customers to survive.
Nokia was interested in a common API for their platforms (S40, Symbian & Maemo / MeeGo). Huge investments have been received in Qt. We have long wanted to develop a cross-platform IDE, but there was no means. The guide offered Eclipse, but it is not very good for C ++. With Nokia, our desire became possible and was created by Qt Creator. And also Qt Quick. We also began to work on the integration of the WebKit engine. Nokia changed the license from the GPL to the LGPL, which made the framework even more free.
In 2012, we broke up with Nokia.
Digia acquired Qt.
Porting to new platforms was difficult, so they added a layer of abstraction. We did a good job on the graphical interface, it stopped being static. For example, this can be seen in the Dock Widget window during the move.
250 employees, annual income of 32 million euros. About a million active users.
Our goals:
C ++ has a very steep learning curve, which makes it hard for newbies. All this complexity is required in rare cases. And Qt is not only used by C ++ gurus. You rarely see an application developer fiddling with patterned metaprogramming.
[It is superficially told about the basics of QObject, Signals / Slots, moc, about which it is written in any manual, missed ]
Read more: Implicitly shared
Many classes are implemented like this:
class QFont { void setPointerSize(int pt) { if (d->refCount != 1) detach(); d->pointSize = pt; } private: detach(); QFontPrivate *d; }; class QFontPrivate { QBasicAtomicInt refCount; int pointSize = -1; int weight = QFont::Normal; };
This allowed us to be more free when adding and removing members of a class. When you change an object, a copy of the internal data is created. The advantages of this approach:
Disadvantages:
for(auto c : qvector) // (detached) for(auto c : qAsConst(qvector)) //
[ In the first line, detach is actually called, but the creation of an internal copy will occur only if the counter is greater than one, for example: ]
QVector<int> v1 = { 1, 2, 3 }; QVector<int> v2 = v1; // , v1 v2 for (auto c : v1) // , v1.begin()
[ The very, very basics of QML, nothing new. Missed ]
Enabling various graphics APIs in Qt Scene (OpenGL, Vulkan, Metal, Direct3D, Software Rasterization)
We use C ++ 11 to the extent that VS2013 allows. We would like to use:
We are already using __has_include
, [[deprecated]]
, [[fallthrough]]
, [[nodiscard]]
. Added QStringView.
It could be very interesting for Qt: concepts, modules, reflection (maybe it would even be possible to get rid of moc sometime in the future).
What do you think about Qt security?
Of course, we are working on it, spending a lot of time, releasing patches, updates. Our security mailing list is quite small.
How do you pronounce: “kyutI” or “kyuT” [ very soft “t” in both cases ]?
Good question! Our company and those who work with us use kyuT, although in the United States it is predominantly kyuT. [ And how are you? Added poll ]
Qt programming is different from C ++ programming. What do you think about duplication of functionality - for example, QVector and much more? Planning to merge or what?
Ideally, yes, but there are problems. First, because of the support of the old code. Secondly, some Qt classes are better, for example QString (interface methods such as case conversion, unicode). Ask a lot of questions about similar containers. I advise you to choose the most suitable.
Now Qt uses raw owning pointers. Is it time to replace them with smart ones? Now an object with a smart pointer cannot be passed to Qt, because it will have a parent.
It is very difficult. And all the old code will break.
If your code is open source, then where does the income come from?
From sales of the commercial version.
Why not add a displacement constructor to QObject and derived classes? With the copy constructor, this is understandable [ why there is no copy constructor ].
Everything will break. If we had foreseen the appearance of the semantics of displacement, then perhaps we would not use the current mechanism. Now it is impossible to change it.
Did you evaluate the performance of the copy-on-write model for strings versus simple copying?
For shorter lines, copying is faster. An update will be released soon, which will implement a similar mechanism for short lines.
How about support for other graphics APIs?
If we are talking about 3D API, such as Apple Metal, Vulkan, Direct 3D 12, then it is difficult.
Source: https://habr.com/ru/post/339180/
All Articles