I've used Qt in the past and current. Qt is big and, while it might be sufficiently architected, I wouldn't describe it as well architected. There's a lot of Qt-isms that don't follow modern C++ paradigms. The concept of shallow- and deep- copy is particularly frustrating, everything that's based in QObject can't be moved, and a lot of the objects simply _aren't_ extensible enough. Qt's QNetworkAccessManager is probably one of the least-acceptable (or extensible) network access libraries; good luck adding support for custom types of proxies or schemes.
What do you mean is big? How much % of your RAM will a Qt application take?
What I mean by well architected is that:
1 it respects the user choice so it tries to use the user themes, icons , fonts (it would do a even better job if Miscrosoft and Apple would contribute a bit when they change their designs)
2 it is efficient, it does not use some hacky stuff like you see in angular or react, where one click causes some data to change then a lot of code runs and check what changed where, then try see what other data needs to change then finally updates the DOM, which DOM is a super complex piece of software that is super easy to eat a lot of CPU with just a line of CSS or cause a lot of recalculations when you update one item.
3 Qt gives you a lot of widgets to build on top of, I remember it had a lot of APIs not only for GUI but also networking, desktop integration(like to use the native notifications)
4 I loved the fact Qt had it's own standard library, I know some c++ purists won't like that and the qmake , but we need to understand how many platforms Qt targeted and that the col new C++ features were not there on all this platforms when Qt4 was created (and even with Qt4 I think there was a way to upgrade from Qt3 so there was not a complete start from scratch).
I assume there are some smaller toolkits, there are some posted here but I think the smaller ones have only 20% of the features.
IMO the reason Qt is not used as much is because it uses C++ , for modern application I think developers prefer garbage collected languages and Qt (last time I checked) did not had mature bindings for this popular languages.
Sorry for the long comment, what would you use today if you need to make an application for someone, something simple like some buttons, menus and it does a bit of work maybe with some files or the internet), the goal is to be fast and have very few bugs that you will have to support by fixing them.
> I loved the fact Qt had it's own standard library, I know some c++ purists won't like that and the qmake , but we need to understand how many platforms Qt targeted and that the col new C++ features were not there on all this platforms when Qt4 was created
Indeed so! Qt is living today with the fact that it was built and designed long before C++11 was really a thing (where C++11 is the baseline of modern C++ and I would argue that even C++17 should be considered the baseline). The design decisions of Qt are directly against modern C++ design. I think that's ultimately the core of the problem: that modern Qt is orthogonal, not complementary, to modern C++.
Range-for loop? Oops, accidentally detached and deep-copied into a temporary.
Move objects? Just, no.
unique_ptr? Nah, QScopedPointer. Also still not moveable. make_unique? Nah, reset(new...) and ignore the modern advice that you shouldn't use `new`
Qt still takes naked pointers and decides willy-nilly whether to take ownership. It still has examples everywhere for using naked new without even mentioning the context of a smart pointer. It has the concept of "you used new, but the parent actually owns it, unless the parent is null" which is just a time bomb for anyone new to the framework let alone the language.
No, there's no way I would recommend Qt to someone who isn't experienced. Since I wouldn't recommend it then it's no wonder to me why Qt isn't used so much. It has little to do with C++ and a lot more to do with the design decisions of Qt itself.
> IMO the reason Qt is not used as much is because it uses C++
Arguably. Also arguably is because Qt brings along a lot of unnecessary baggage. You mentioned using Qt requires using qmake (which definitely counts as arcane, if not archaic); cmake does a pretty good job of wrapping qmake but doesn't eliminate it. And all of that is because of Qt's non-standard magical signals & slots system which is really just a more error-prone semi-async system when compared to any other eventing system.
Using Qt efficiently strongly needs Qt Creator which isn't nearly as good as Visual Studio or VS Code and not as feature-rich as CLion or other intellij-based IDEs I've used -- but at least it performans way better than CLion or intellij trash.
Qt's license changing in 5.15 has also become a significant penalty to non-commercial use. This fact alone means there's no way I'd use Qt in a new project, even a commercial one.
Modern Qt developers also have to become javascript developers since Qt's UI is heavily driving towards QML. That's an unfortunate direction and also inhibits adoption of Qt IMO. Why write an application in C++ if you need to learn javascript anyway? There are better feature-rich javascript frameworks with better community adoption and better price points.
> what would you use today if you need to make an application for someone, something simple like some buttons, menus and it does a bit of work maybe with some files or the internet), the goal is to be fast and have very few bugs that you will have to support by fixing them
For GUI, Dear Imgui [0].
For network, Asio [1].
For files, plain standard streams. They're not fast but if your files are your bottleneck then I'd consider memory-mapped files.
Your suggestions are not compatible with what I was thinking , my scenario was that "I need to write a small application very quickly" not "I am staring a bussiness and I want to spend a few years developing an application", What I mean is that with Qt you have more then a GUI, you don't have to Google what library I need to do some networking , or what is the win32 API to count how many screens this PC has (and same for the other platforms). I did not work on Desktop application in many years so I am not sure what exactly is happening in Qt world now and for a quick project I don't want to learn some niche libraries .
> Your suggestions are not compatible with what I was thinking , my scenario was that "I need to write a small application very quickly" not "I am staring a bussiness and I want to spend a few years developing an application"
I disagree; it's very possible to write a small application very quickly in modern C++ without Qt.
> with Qt you have more then a GUI, you don't have to Google what library I need to do some networking
If you are new to Qt then you do need to google how to use Qt.
On the flip side, if you're not new to whatever other library you want to use for networking then you don't need to google to use that. Indeed, I don't need to use Google to figure out how to use asio and beast to connect to a server and download data using http.
> or what is the win32 API to count how many screens this PC has
What small application needs to know how many screens this PC has? I definitely don't consider that a small application and I would need to go "Google" how to get that information out of Qt.
I would just as quickly find that information from Xlib because fuck Windows.
> for a quick project I don't want to learn some niche libraries
For a quick project I don't want to use Qt. Your argument is merely an opinion.
It can be frustrating indeed that Qt is not quite C++, make no use of modern C++ library, and requires a preprocessor.
Still, I find it debatable whether modern C++ is so much better than Qt. Qt design principles might lead to less performance but I, for one, find the design consistent and solid.
The main advantage of Qt over modern C++ though is its stability. If you had written a Qt app 20 years ago it would still compile and work as intended, whereas C++ become a different language every 5 years.
I share your sentiment about QML though, and hope they will quickly reinvest into Qwidgets.
> The main advantage of Qt over modern C++ though is its stability.
Yes
> main advantage of Qt over modern C++ though is its stability. If you had written a Qt app 20 years ago it would still compile and work as intended, whereas C++ become a different language every 5 years.
Your arguments contradict eachother.
C++ only becomes another language every 5 years if you want to use the new features. The new features make things simpler and safer.
I say I do want to use the new features; I want the safety improvements and the simplicity offered. Qt makes it practically impossible to do.
Note that you don't strictly need moc when coding Qt app. I use verdigris which is an equivalent of moc but entirely implemented as macros. The drawback is that since C++ does not yet have proper reflection, the macros are a bit uglier...
Most of your points revolve around QObject's having its own ownership and lifetime model, of course it will be extremely painful to work against that. No surprise there. QObject ownership is sound and quite practical though, as long as you're not actively trying to work against it. It's certainly not complicated.
> Also arguably is because Qt brings along a lot of unnecessary baggage. You mentioned using Qt requires using qmake (which definitely counts as arcane, if not archaic); cmake does a pretty good job of wrapping qmake but doesn't eliminate it.
CMake does not invoke qmake for Qt projects. It does invoke moc though. Perhaps you meant that you need to use moc? That's mostly true, though verdigris does work and only requires a modern C++ compiler.
> And all of that is because of Qt's non-standard magical signals & slots system which is really just a more error-prone semi-async system when compared to any other eventing system.
Signal-slot is simply a convenient way to declare events (signals) and connect callbacks (slots) to them, using implicit per-thread event queues. Pretty standard stuff.
> Modern Qt developers also have to become javascript developers since Qt's UI is heavily driving towards QML.
This is simply false. Qt contains two separate UI systems for two very different use cases. Qt Widgets does not use QML (or JS) and is your classic CPU-rendered desktop toolkit. Qt Quick is a declarative UI framework designed for layer-based GPU compositing, mainly aimed at mobile, embedded and "graphically rich" interfaces.
You can write Qt applications for years and years and not even know how JS is spelled.
> For GUI, Dear Imgui [0].
Imgui is a nice library, but it lacks a very large number of features you'd want in a desktop application, all of which you'd have to write yourself. Some of which you'll have a hard time developing (e.g. accessibility). This is of course because Imgui isn't meant to be a general-purpose GUI library for desktop applications.
> For files, plain standard streams.
It's kinda funny that you complain so much and then recommend iostreams of all things.
> CMake does not invoke qmake for Qt projects. It does invoke moc though. Perhaps you meant that you need to use moc?
Indeed
> Signal-slot is simply a convenient way to declare events (signals) and connect callbacks (slots) to them, using implicit per-thread event queues. Pretty standard stuff.
They're not convenient because they're not standard and require ~~qmake~~moc. A regular function with a regular event loop is convenient. But Qt doesn't let you poke around its event loop without using signals and slots.
> Imgui is a nice library, but it lacks a very large number of features you'd want in a desktop application, all of which you'd have to write yourself.
Maybe in a full desktop application but remember the idea is for a small one.
> Some of which you'll have a hard time developing (e.g. accessibility).
A small free application doesn't need accessibility to be useful to the author.
> This is of course because Imgui isn't meant to be a general-purpose GUI library for desktop applications.*
If you say so.
> It's kinda funny that you complain so much and then recommend iostreams of all things.
iostreams are just as easy as qt and without the bloat needed for it.
> They're not convenient because they're not standard and require ~~qmake~~moc. A regular function with a regular event loop is convenient. But Qt doesn't let you poke around its event loop without using signals and slots.
Like I said, you don't have to use moc, there are alternatives. Also, Qt has supported "regular functions" for many years, since you can use connect() with function pointers, PTMFs, lambdas etc.
The only difference between a "regular function" and a slot: method is that the latter has some extra RTTI data which allows it to be safely called from dynamic bindings. Another use-case is old-style (Qt 4) connect where you pass the slot name as a string and connect() has to look-up the method pointer at runtime (and also checks parameter types etc.). That's a rare sight, though.
> iostreams are just as easy as qt and without the bloat needed for it.
iostreams is an atrocious API and bloaty on top. Easily the worst library in the C++ standard (in no small part due to its sheer age, being one of the oldest parts of the language).
Regarding QObject, you know the difference between identity objects and value objects? QObjects are identity objects. I sometimes see people using them as value objects (bags of data), and that is not what they are for. It's terribly inefficient, for starters.
What do you mean ? You mean I should have avoided using QString ? I created a program once and I wanted to be pure c++ in the algorithm part so I used the std::string there but I suppose some C dev will tell me that char[] is faster.
Usualy QObject based classes are needed to get the GUI working.
I've used Qt in the past and current. Qt is big and, while it might be sufficiently architected, I wouldn't describe it as well architected. There's a lot of Qt-isms that don't follow modern C++ paradigms. The concept of shallow- and deep- copy is particularly frustrating, everything that's based in QObject can't be moved, and a lot of the objects simply _aren't_ extensible enough. Qt's QNetworkAccessManager is probably one of the least-acceptable (or extensible) network access libraries; good luck adding support for custom types of proxies or schemes.