Qt: What's it all about? Is it good, or is it whack?



  • In another thread :arrows: there was a bit of discussion about Qt, and I thought I might want to get familiar with it. I had tried it a few years ago, but couldn't get past the clunky "Qt Creator" IDE. So I've got some questions about it:

    • Can I use a non-stupid IDE, and would I still need to keep Qt Creator for anything? And/or has Qt Creator improved to a usable state?
    • Can you use native controls?
    • Any good, up-to-date tutorials to get started with it?

  • BINNED

    I used to use Visual Studio on Windows but I’m almost exclusively using Qt Creator on Linux now. It has tremendously improved, but I assume so have other IDEs. You don’t really need it, though.
    There’s some Qt tools integration for VS, but I’m not sure what they do. qmake can create visual studio project files, so you can use those. Or make, if you prefer.

    As far as controls go, there’s either the old-school “widgets” based ones or the new “QML” based ones, which are some funky JS dialect. What exactly do you mean with native controls?
    I’m not familiar with the QML stuff, but the controls in the widgets API use the platform’s native theming API to look reasonably native. They don’t, however, create native “windows” for every widget, like an actual HWND on Windows. You can force that on, but normally don’t want to. I assume most modern stuff like C# UIs behave the same in only using lightweight instead of OS controls.

    No idea about tutorials, the ones I read where ages old.



  • @hungrier I've been using it as my main toolkit for years, so I am somewhat biased about it (something like Stockholm syndrome, I've learnt to like even some crappy parts...).

    You can absolutely use any IDE with it, it's just a C++ library, so you can just configure your project to use it as any other library and ignore most of Qt's tools (some of them are mandatory but most build systems (we use CMake) abstract that pretty well).

    When working on Windows I use it with Visual Studio and the only thing I had to tweak is to add a module to be able to debug easily Qt's data structures (e.g. see what's inside a QString without having to care about the weird internal members).

    That said, you won't have a GUI GUI designer. If you want that I think that the only way is to use Qt Designer (which I think you can use as standalone, outside of Qt Creator?). I personally don't use Qt Designer because 1) I learnt Qt at a time when it didn't exist so I got used to not having it (:belt_onion:) and 2) I strongly dislike the mess of the intermediate files that using Qt Designer implies, particularly when you need to customise a bit the widgets (i.e. subclass them). But if you just build a basic UI, and don't try to fight it too much, it's reasonable (some colleagues use it).

    (also I find that building UIs "by hand" i.e. by directly writing the code isn't that much of an issue, it forces you to think a bit more about how you want to lay out things which is rather a good thing, and then it's just the slightly tedious bit of putting an horizontal box into a vertical box into another vertical box, and a label and a checkbox inside the box and so on, which you get quickly used to)

    On Linux, I do use Qt Creator, and I quite like it. Overall, compared to VS, I can't really say that one is better than the other on all fronts. VS is better for debugging, Qt Creator is better for navigating/searching code (although VS does improve). But it's really down to personal taste at that point. I'd say it's usable, although if one of the missing/broken feature is something you rely upon, it's going to be awful to you even if it's perfect for someone else. So... YMMV, I guess?

    I'm not sure whether you can mix native controls with Qt's controls, I've never done so (one of the draws of Qt for us is the cross-platform thing, so using native stuff would be pointless). There are a few parts deep down where you can get generic pointers to basic stuff (HANDLE etc.) so I guess it might be possible to hook native stuff from there, but I don't think that would be plain sailing. I have never seen it put forward as something you can do with Qt, so I assume that if you do it's not going to be standard. But really, I have no idea.

    As for the last point, I've been using it for far too long to have any idea which tutorials are any good. Qt's doc tends to be relatively good, so their tutorial is probably not awful, although OTOH there was at least once where I looked at it and it was using a bit of tech that they were (had?) deprecating, so learning with it wouldn't have been good... But again, I don't really know.



  • @topspin said in Qt: What's it all about? Is it good, or is it whack?:

    I used to use Visual Studio on Windows but I’m almost exclusively using Qt Creator on Linux now

    I use VSCode on Linux. But just to edit (and debug). Compiling is done on the command line (and ultimately inside a docker image with cmake).



  • BTW, having used both Qt and wxWidgets now, I'll stick with wxWidgets for my personal stuff...



  • @topspin said in Qt: What's it all about? Is it good, or is it whack?:

    As far as controls go, there’s either the old-school “widgets” based ones or the new “QML” based ones, which are some funky JS dialect. What exactly do you mean with native controls?

    I mean ones that look like the normal controls of the OS they're running on, as opposed to something funky like Java's default Swing look-and-feel. From what you've described, "widgets" sounds like it.


  • Banned

    Using Qt implies using C++. If you can, avoid doing any GUI work in C++, it's just too painful. But if you're stuck with C++ for whatever reason, Qt is the best there is.

    Official docs have relatively good tutorials.



  • @remi said in Qt: What's it all about? Is it good, or is it whack?:

    (also I find that building UIs "by hand" i.e. by directly writing the code isn't that much of an issue, it forces you to think a bit more about how you want to lay out things which is rather a good thing, and then it's just the slightly tedious bit of putting an horizontal box into a vertical box into another vertical box, and a label and a checkbox inside the box and so on, which you get quickly used to)

    I've done a lot of UIs this way so that's not too bad.

    @remi said in Qt: What's it all about? Is it good, or is it whack?:

    (one of the draws of Qt for us is the cross-platform thing, so using native stuff would be pointless).

    There are some aspects of look-and-feel that don't translate directly between OSes (UI guidelines like having save/cancel arranged a certain way, in one corner of the dialog) but that's a separate issue from being able to say "put a generic button/dropdown/scrollbar/etc and let the OS take care of drawing it"



  • @dcon said in Qt: What's it all about? Is it good, or is it whack?:

    wxWidgets

    Can you tell me a bit more about that? I've heard the name but not much else.



  • @Gąska said in Qt: What's it all about? Is it good, or is it whack?:

    Using Qt implies using C++. If you can, avoid doing any GUI work in C++, it's just too painful. But if you're stuck with C++ for whatever reason, Qt is the best there is.

    Official docs have relatively good tutorials.

    I'd rather use C# but as far as cross-platform stuff goes, I'm under the impression that it's a mess, and even more of a mess with each .NET Core version that gets released


  • BINNED

    @remi said in Qt: What's it all about? Is it good, or is it whack?:

    QString

    Speaking of that: Qt reinvents a lot of things like containers from the standard library, e.g. QVector over std::vector, and offers e.g. normal C++ APIs and Java style APIs for iterators. That's a relic from a time when their stuff was just plain better than the std counterparts, but that's no longer true. So I'm trying to stick to standard library stuff more, but for interfacing with Qt you're often better off with their types. QString in particular is way better than std::string, so while you already have the large Qt dependency, you don't need to bring in garbage from boost just to get trivial functions like trim or split or join.
    And it's Unicode so you don't have to mess around with std::wstring on Windows.

    That said, you won't have a GUI GUI designer. If you want that I think that the only way is to use Qt Designer (which I think you can use as standalone, outside of Qt Creator?). I personally don't use Qt Designer because 1) I learnt Qt at a time when it didn't exist so I got used to not having it (:belt_onion:) and 2) I strongly dislike the mess of the intermediate files that using Qt Designer implies, particularly when you need to customise a bit the widgets (i.e. subclass them). But if you just build a basic UI, and don't try to fight it too much, it's reasonable (some colleagues use it).

    I use the designer now, it's pretty simple but not exactly amazing. Doing it manually is easy enough though.

    I'm not sure whether you can mix native controls with Qt's controls, I've never done so (one of the draws of Qt for us is the cross-platform thing, so using native stuff would be pointless). There are a few parts deep down where you can get generic pointers to basic stuff (HANDLE etc.) so I guess it might be possible to hook native stuff from there, but I don't think that would be plain sailing. I have never seen it put forward as something you can do with Qt, so I assume that if you do it's not going to be standard. But really, I have no idea.

    You can do that, but I doubt that was what's being asked.
    I had to do it once when I wrote a Qt based plugin for an Autodesk program, and it worked out well enough with the right bit of platform integration hack. The problem is that, unlike libraries, "frameworks" like to take over control, and if you're running inside of another process you don't have a QApplication that serves as the main message pump, so you need to integrate into the host's native message pump somehow. It's possible, but kind of ugly.

    As for the last point, I've been using it for far too long to have any idea which tutorials are any good. Qt's doc tends to be relatively good, so their tutorial is probably not awful, although OTOH there was at least once where I looked at it and it was using a bit of tech that they were (had?) deprecating, so learning with it wouldn't have been good... But again, I don't really know.

    Yeah, the API reference docs are for the most part pretty good, but some of the examples are severely dated. Even the "demos" on the welcome page of Qt Creator have stuff that gives of a 90s vibe from the screenshots.


  • ♿ (Parody)

    @hungrier said in Qt: What's it all about? Is it good, or is it whack?:

    @dcon said in Qt: What's it all about? Is it good, or is it whack?:

    wxWidgets

    Can you tell me a bit more about that? I've heard the name but not much else.

    I've used it in the past. Basically, they have different builds, so there's a Windows build that uses native Windows, a GTK build that uses GTK on *nix and there were some Mac type stuff (I've never used it). As I say, haven't used it in forever but it worked really well for cross platform stuff and it generally is native (aside from complicated stuff like a spreadsheet grid, which doesn't have a "native" control anyways).



  • @hungrier said in Qt: What's it all about? Is it good, or is it whack?:

    @dcon said in Qt: What's it all about? Is it good, or is it whack?:

    wxWidgets

    Can you tell me a bit more about that? I've heard the name but not much else.

    It's a cross platform (C++) toolkit that tries to use native controls as much as possible. It has multiple bindings so you can use it from other languages, like Python.

    (I also subscribe to https://groups.google.com/g/wx-users and https://groups.google.com/g/wx-dev. The later is for developer of wxwidgets, the former is for developers using it)

    When I first started, I used wxFormBuilder (still do a little) to design and understand how the layout stuff worked. I would then copy/paste the C++ code into my program. You can also design/load the forms using XRC (xml).


  • BINNED

    @hungrier said in Qt: What's it all about? Is it good, or is it whack?:

    There are some aspects of look-and-feel that don't translate directly between OSes (UI guidelines like having save/cancel arranged a certain way, in one corner of the dialog) but that's a separate issue from being able to say "put a generic button/dropdown/scrollbar/etc and let the OS take care of drawing it"

    Qt actually has abstractions for that. QDialogButtonBox "is a widget that presents buttons in a layout that is appropriate to the current widget style", i.e. changes layout depending on OS. QMenuBar automatically integrates your normal menu bars you know from windows into the single menu bar at the top of the screen on macOS.

    But yes, the look-and-feel is so that Qt takes care of the drawing, but uses the OS theming API to do it. Works great on Windows, is "native" anyway on KDE, could be improved a bit on mac.


  • Banned

    @boomzilla I tried using wxWidgets once, some 12 years ago. Back then I couldn't get it to work. Maybe it has improved since, but it's open source, so my hopes are low.


  • ♿ (Parody)

    @Gąska dunno. I was definitely using it back then.


  • BINNED

    @Gąska said in Qt: What's it all about? Is it good, or is it whack?:

    Using Qt implies using C++. If you can, avoid doing any GUI work in C++, it's just too painful. But if you're stuck with C++ for whatever reason, Qt is the best there is.

    Official docs have relatively good tutorials.

    There's Python bindings for it (even official ones, now). I've used them, but I'm personally not convinced. I'd rather have the pain of C++ than the pain that is duck-typing and messing with errors at runtime.


  • Banned

    @boomzilla it might also be because I was 13 back then. On the other hand, Qt gave me zero issues at that time (other than the usual C++ crap and the usual GUI crap).



  • wxWidgets

    Apparently you can use wxWidgets with C#, but I haven't found much for that aside from something that hasn't been updated in nearly a decade. Does anyone know about wxWidgets and C#? Or for that matter Qt with C#, although with Qt I'm now a bit leery about their license.



  • I got a notification that @boomzilla mentioned me, but it points to a post that doesn't seem to exist :wtf:


  • ♿ (Parody)


  • BINNED

    @hungrier said in Qt: What's it all about? Is it good, or is it whack?:

    I'm now a bit leery about their license.

    LGPL is not problematic, really. Just use dynamic linking like you'd do anyway (you have to go out of your way to statically link to Qt). It's GPL that you have to beware of in a framework.



  • @hungrier said in Qt: What's it all about? Is it good, or is it whack?:

    although with Qt I'm now a bit leery about their license

    That's why I'm staying away from it for the personal and open source stuff.



  • @dcon why? As :@topspin said, Qt with its LGPL is fine to link against. PyQt on the other hand, with its GPL license, I wouldn't want to touch with a 10foot pole...


  • I survived the hour long Uno hand



  • @robo2 said in Qt: What's it all about? Is it good, or is it whack?:

    @dcon why? As :@topspin said, Qt with its LGPL is fine to link against. PyQt on the other hand, with its GPL license, I wouldn't want to touch with a 10foot pole...

    I statically link. Some of my users can't run installers. And trying to explain 'unzip this somewhere' is way beyond them.

    Question: Can you easily compile and run a Qt program in Visual Studio like a normal C++ program? Or do you have to use their IDE (or compile with cmake)? (I currently only use it on linux with cmake)


  • Banned

    @dcon said in Qt: What's it all about? Is it good, or is it whack?:

    Question: Can you easily compile and run a Qt program in Visual Studio like a normal C++ program?

    Yes. There's even a special plugin for easy integration of Qt with Visual Studio, developed by Qt devs themselves.



  • @dcon said in Qt: What's it all about? Is it good, or is it whack?:

    users ... way beyond them

    :surprised-pikachu:


  • BINNED

    @dcon said in Qt: What's it all about? Is it good, or is it whack?:

    I statically link. Some of my users can't run installers. And trying to explain 'unzip this somewhere' is way beyond them.

    Tell them to get a mac, which can treat a whole folder like an app. And send them a reminder once in awhile that they shouldn’t forget to breathe.



  • @topspin said in Qt: What's it all about? Is it good, or is it whack?:

    Tell them to get a mac

    You're an evil person.



  • @dcon If you statically link you must buy a commercial license to use Qt. Or open-source everything.



  • @magnusmaster said in Qt: What's it all about? Is it good, or is it whack?:

    @dcon If you statically link you must buy a commercial license to use Qt. Or open-source everything.

    "commercial license" :rofl: For a program I get no money for, I'm not spending $3950/yr.
    edit: Ah, check the little "less than 250K annual revenue" box and it drops to 499.

    I'm doing it under the MIT License. I was tempted to use the WTFPL.



  • @Gąska said in Qt: What's it all about? Is it good, or is it whack?:

    Using Qt implies using C++. If you can, avoid doing any GUI work in C++, it's just too painful.

    Isn't that what QML is for? So I don't see the problem, since in a modern Qt application you wouldn't use C++ for everything.


  • Discourse touched me in a no-no place

    @topspin said in Qt: What's it all about? Is it good, or is it whack?:

    could be improved a bit on mac

    The problem is that the platform guidelines for how to lay your application out are different on a Mac to on Windows. You can't make things feel native by just changing how they are drawn, and must instead change around where they are drawn and (in some cases) what widget type you use.



  • @hungrier said in Qt: What's it all about? Is it good, or is it whack?:

    I've done a lot of UIs this way so that's not too bad.

    Yeah, I don't have any issues with it either, but I could understand if someone hated it, because ultimately it's a lot of boring code with some boilerplate and a few gotchas that you need to learn. Probably not worse that any library to do anything, but still a bit of work and getting used to.

    There are some aspects of look-and-feel that don't translate directly between OSes (UI guidelines like having save/cancel arranged a certain way, in one corner of the dialog) but that's a separate issue from being able to say "put a generic button/dropdown/scrollbar/etc and let the OS take care of drawing it"

    Oh, right, I didn't understand what you meant by "native" correctly. As said by @topspin, Qt does its best to blend into OS style (when there is one... on Linux it more or less defines the KDE style by itself since KDE is Qt-based). It's not perfect though, when you're used to it you can spot a Qt application on Windows, but it's nowhere as ugly as a Java UI. The "native look but you don't need to worry about" can also sometimes cause you some issues when it interferes with your own code (if you start reimplementing a dialog then you may need to be wary about this button order thing), but it's usually fairly small and not really noticeable unless you do complicated or iffy things (inb4: most complicated things are iffy :trollface:).



  • @Gąska said in Qt: What's it all about? Is it good, or is it whack?:

    Using Qt implies using C++

    That's not quite true. These days I've been using Qt mostly as a GUI toolkit from python (via PySide2). I've found the experience surprisingly non-painful, the python integration is quite well-done considering the circumstances. The native python types (list, string, ...) are transparently mapped to the corresponding Qt types, the entire API is available and maps to python in a straightforward way, the signals / slots integration is rather neat and you don't need all the code generation / MOC shenanigans.

    @topspin said in Qt: What's it all about? Is it good, or is it whack?:

    I'd rather have the pain of C++ than the pain that is duck-typing and messing with errors at runtime.

    Well yes, if you use the python bindings you will end up having to code in python. I like it quite well for personal projects but I'm not sure how I'd feel about working with a team on a bigger application.


  • Considered Harmful

    @dcon said in Qt: What's it all about? Is it good, or is it whack?:

    Some of my users can't run installers.

    I've seen a lot of Windows apps installing into %LOCALAPPDATA%, that way they don't need admin privileges. I'm sure there are similar approaches for other OSes.



  • @error said in Qt: What's it all about? Is it good, or is it whack?:

    @dcon said in Qt: What's it all about? Is it good, or is it whack?:

    Some of my users can't run installers.

    I've seen a lot of Windows apps installing into %LOCALAPPDATA%, that way they don't need admin privileges. I'm sure there are similar approaches for other OSes.

    At least one of my users can't install anything. Plus, by static linking, I don't have to worry about installing the VC runtime.


  • BINNED

    I just decided to have a look at Qt Quick, having only used Widgets so far, and created a new project in Qt Creator. Select the template "Application (Qt Quick)" -> "Qt Quick Application - Stack".
    Hmm, one main file that creates the application and everything else in .qml files. How do I interact with these? Would have to read the docs. Let's have a look around first, though. Open one of the pages (it's a simple application that shows one "main page" with a hamburger menu that can open two sub pages) in the designer:

    qtquick_garbage.png

    :vomit: :vomit: :vomit:

    What hot mess is this?!

    Maybe I just react too strongly to generic "dark mode" nonsense that is so modern1, where everything is completely desaturated light-gray on dark-gray. But this just looks terrible at first glance.
    Everything overlaps. There's ellipses everywhere. Even the simplest texts like "100%" or "Rectangle" are spelled "10..." or "Rec...gle" instead, so a majority of controls are unreadable. Not like there's a ton of space between "Override He..." and the indecipherable stuff that looks like fly shit next to "10...".
    And of course, since you can't read the text, you have to rely on icons, all of which look the same. That's not progress, that's going 20 years backwards.

    Assuming they used Qt Quick to create this designer, if that's what it looks like I'll stick with Qt Widgets! TYVM.

    1 Fuck, do I hate dark mode. :belt_onion:



  • @topspin said in Qt: What's it all about? Is it good, or is it whack?:

    Assuming they used Qt Quick to create this designer, if that's what it looks like I'll stick with Qt Widgets! TYVM.

    Bad designers can make bad designs in good tools.


  • BINNED

    @HardwareGeek said in Qt: What's it all about? Is it good, or is it whack?:

    @topspin said in Qt: What's it all about? Is it good, or is it whack?:

    Assuming they used Qt Quick to create this designer, if that's what it looks like I'll stick with Qt Widgets! TYVM.

    Bad designers can make bad designs in good tools.

    Obviously, but you'd think this is kind of their dog-fooding showcase.


  • Discourse touched me in a no-no place

    @ixvedeusi said in Qt: What's it all about? Is it good, or is it whack?:

    I'm not sure how I'd feel about working with a team on a bigger application.

    BTDT (we're locked into Python by user expectations). It takes discipline. Document what types each function and each method takes. Or use type annotations if you're using a new enough version. (We're still supporting stuff too old for that.) There are quite a few tools to help out; integrate them into your CI flow and the IDEs in use.


  • Banned

    @topspin said in Qt: What's it all about? Is it good, or is it whack?:

    Everything overlaps. There's ellipses everywhere. Even the simplest texts like "100%" or "Rectangle" are spelled "10..." or "Rec...gle" instead, so a majority of controls are unreadable. Not like there's a ton of space between "Override He..." and the indecipherable stuff that looks like fly shit next to "10...".

    Add it to the Big List of Software That Pretends To Do UI Scaling But Was Never Tested With Anything Other Than 100%.


  • BINNED

    @Gąska said in Qt: What's it all about? Is it good, or is it whack?:

    @topspin said in Qt: What's it all about? Is it good, or is it whack?:

    Everything overlaps. There's ellipses everywhere. Even the simplest texts like "100%" or "Rectangle" are spelled "10..." or "Rec...gle" instead, so a majority of controls are unreadable. Not like there's a ton of space between "Override He..." and the indecipherable stuff that looks like fly shit next to "10...".

    Add it to the Big List of Software That Pretends To Do UI Scaling But Was Never Tested With Anything Other Than 100%.

    It's not even scaled (that I'm aware of). It's running maximized on 1080p, giving it a client area size of 1920*977 pixels. Do you need 4K to run this?
    Besides some minor annoyances, it doesn't normally look like that in the other modes.


  • Banned

    @topspin the screenshot looks like the text font is too large for the buttons. This usually happens when some UI elements scale properly but others don't. A higher resolution won't help.

    Or maybe they're just idiots who never tested their app at all. Which wouldn't really surprise me.


  • Discourse touched me in a no-no place

    @topspin said in Qt: What's it all about? Is it good, or is it whack?:

    Maybe I just react too strongly to generic "dark mode" nonsense that is so modern1, where everything is completely desaturated light-gray on dark-gray. But this just looks terrible at first glance.

    That's poorly implemented dark mode though.

    @topspin said in Qt: What's it all about? Is it good, or is it whack?:

    Fuck, do I hate dark mode.

    No-one's perfect.



  • @Gąska said in Qt: What's it all about? Is it good, or is it whack?:

    Add it to the Big List of Software That Pretends To Do UI Scaling But Was Never Tested With Anything Other Than 100%.

    ACROBAT!!! (and $deity help you if you run on 2 monitors with different scaling)


  • Banned

    @loopback0 said in Qt: What's it all about? Is it good, or is it whack?:

    @topspin said in Qt: What's it all about? Is it good, or is it whack?:

    Maybe I just react too strongly to generic "dark mode" nonsense that is so modern1, where everything is completely desaturated light-gray on dark-gray. But this just looks terrible at first glance.

    That's poorly implemented dark mode though.

    But you repeat yourself.



  • @topspin Really a good post.

    As for QtCreator, I think it's quite a decent IDE. It's easy to navigate through large projects with it (easier than in VSCode, in my opinion) and it integrates well with the build system, debugger etc. You do need to give it a suitable cmake project. QtCreator doesn't seem to digest our cmake files at work, for example.


  • Trolleybus Mechanic

    @Gąska said in Qt: What's it all about? Is it good, or is it whack?:

    @loopback0 said in Qt: What's it all about? Is it good, or is it whack?:

    @topspin said in Qt: What's it all about? Is it good, or is it whack?:

    Maybe I just react too strongly to generic "dark mode" nonsense that is so modern1, where everything is completely desaturated light-gray on dark-gray. But this just looks terrible at first glance.

    That's poorly implemented dark mode though.

    But you repeat yourself.

    Dark mode forever! Not exactly dark mode, but it makes me sad when I see people using SSH terminals with white backgrounds and black text. Just seems wrong.


Log in to reply