Qt, note so cute? Have I wasted enough time? - Page 1
Forum section: electronics / general

author: Simon
author_rank: Unknown
timestamp: March 15, 2025, 08:36:03 pm
content: I done some time trying to get into Qt. At the moment my opinion is that it's a steaming pile of dog shit!The documentation that everyone lauds is incomplete or wrong, does not matter which they both amount to the same thing.I spent hours getting the RCC/QRC system to work, the official documentation page is just some nonspecific nonsense. Naturally when I asked on the forum all people would do is point to this documentation calling it definitive. In the end I got it to work after reading several different tutorials and watching several YouTube tutorials and piecing it all together.So I go back to the thread and explain that I got it to work. Oh, now the guy that told me that the official documentation is kings wants to know how I did it. So I did not, yea, becoming a true programmer I am!I explained how the documentation fails and there is of course no response.So as I need to obviously get data from the program (C++) to the display I need to, well you know if you know Qt, C++ class that incorporates the Q_Object, this permits signals and slots that allow this communication between C++ and QML.Naturally nothing works. I tried following a Qt academy tutorial, well that was shit. Instead of just explaining a C++ class with a Qt object using signals and slots they had to over egg it and throw a load more stuff in at which point the whole thing fails to compile and it's just too much thrown it an once.But having tried to get something working myself and doing some more reading I see the same pattern as before when I tried to get the RCC system to work. Documentation is nonsensical and incomplete. There is conflicting information. The more I try stuff the more it falls apart.So, is it really worth it? Surely there is a better way. All I need to do is put things on a screen representing numbers. At some point touch input would be needed. Is Qt this bad or is it something only to be used by the experienced? I've been using the Qt creator IDE, but still with that you end up in this mess.

author: kripton2035
author_rank: Super Contributor
timestamp: March 15, 2025, 08:40:42 pm
content: which end processor/microcontroller/module and display are you using ?

author: BBBbbb
author_rank: Unknown
timestamp: March 15, 2025, 08:51:54 pm
content: Qt is intended as a GUI tool for everything, thus it’s not going to be easy.Not sure about incorrect information in the documentation, I have not run into it. Take care that you are looking at the information for the proper version. Googling can lead you to the wrong one.About being incomplete - I do share that view to an extent, but like you I’m not really a GUI person and lack perhaps some foundation that I expect to be documented.Regarding signals/slots. You will end up using some type of messaging to tie in the GUI. Yes QObject is a pita. Do a nice viewmodel, prefer composition, … and life will be easier.My big issue with Qt is object lifetime which is (to my limited experience) random and thus GUI behavior doesn’t align with my expectations.Also licensing can big a big burden depending on the product.Just my 2 centsThere probably exists a beter option if you focus just on your use case, snoop around.

author: Simon
author_rank: Unknown
timestamp: March 15, 2025, 08:55:10 pm
content: Quote from: kripton2035 on March 15, 2025, 08:40:42 pmI'm planning to use Linux on a single board computer. My limited experience is that HDMI is the minimum standard that does not require linux voodo to get particular displays to work on certain boards/OSes. QSPI could also be an option and often is the only one for smaller screens like 7".

author: Simon
author_rank: Unknown
timestamp: March 15, 2025, 09:16:01 pm
content: Quote from: BBBbbb on March 15, 2025, 08:51:54 pmI initially looked at FLTK. Stroustrops 2nd edition of "programming principles and practice using C++" said that FLTK was practically the de facto standard for graphics in C++. Roll on to edition 3 and now the chapter on graphics is talking about Qt, but it barely mentions that Qt is what was used for the examples. Ah but then the third edition is half the size of the second and frankly is about as useful as the Qt documentation. In fact it reads very much like the Qt documentation...... I wonder who stroustrop let edit his work?Yea, licensing is a nightmare to understand. It looks like someone started an open source project, then changed their mind but it was too late to make the Qt core code chargeable IP so they instead concocted this monumental misunderstood mess that means that people basically pay £4k a year for.... oh, unlimited support, yes because as their website support is so lousy you need private tuition from them direct, I mean really that appears to be the only real difference between the commercial license and the community edition. And now that you have paid £4k to learn how to use it, why on earth would you help some free loader like me an a public forum where anyone can learn what you paid £4k per year for?

author: Smokey
author_rank: Super Contributor
timestamp: March 15, 2025, 09:23:58 pm
content: I used Qt to make a GUI a while back. I found it to be pretty damn good actually. Qt creator was super helpful. Once I got the design paradigm and the window layout system it was pretty straightforward. Lots of information and tutorials available. I'm sure it's only gotten better in the last 6 or so years. Would highly recommend to a friend for a real GUI.Previously I tried WX Widgets, which was much harder to work with. That was about 5 years before the Qt though so WX might have also gotten way better since then. KiCad uses WX so it can't be that bad right

author: Simon
author_rank: Unknown
timestamp: March 15, 2025, 09:29:39 pm
content: No, in the last 6 years they have probably not updated the documentation leaving it out of step with the software.

author: ataradov
author_rank: Super Contributor
timestamp: March 15, 2025, 09:33:34 pm
content: Qt is one of the best if not the best frameworks for desktop stuff. All GUI programming sucks. Qt makes it much easier. Their preprocessor is quite annoying, but it actually enables a lot of functionality that would be hard otherwise. Their documentation is also some of the best I've seen.No idea how it translates to embedded, especially if you don't want traditional standard-looking windows and typical desktop behavior. I get a feeling, it is not the best option for that case.Their licensing is also pretty bad.

author: nctnico
author_rank: Super Contributor
timestamp: March 15, 2025, 10:03:41 pm
content: Quote from: Simon on March 15, 2025, 09:29:39 pmDo yourself a favour and buy a book on how to start projects using Qt and read it. Random internet examples don't work as you still miss learning the fundamentals you need to get started. There are likely several ways on how to organise a project and choosing the right one which is most suitable is the first step.Some people mentioned WX Widgets; for this framework goes the same: buy the book written by the creators. BTW, I have used WxWidgets for many embedded Linux projects to have standard or custom GUIs and I'm quite sure Qt can do the same. With Gnome (GTK) as the presentation layer, you can also do a lot of UI customisation by using different GTK themes and tweaking these to your liking.

author: Simon
author_rank: Unknown
timestamp: March 16, 2025, 06:41:46 am
content: A book you say, have you any recommendations? There seem to be precious few for Qt 6 and none of them have terrific reviews, I have bought one that was very hard to even find and it is all about QML. I need to write a C++ program, if no one wants to explain how to get C++ working with QML then I won't get anywhere. Or is it all done in QML now?They have a PDF book on their site, I was working through that until they "just" put pictures into the QML with no further explanation. That started a 2 week crusade on getting the RCC system to work as this "book" did not mention it at all.I suppose now is the time to be told I don't need QML although my understanding is that the widget system will be obsoleted so I have to use QT (not so) Quick instead of widgets.

author: radiolistener
author_rank: Super Contributor
timestamp: March 16, 2025, 07:57:13 am
content: In my opinion, Qt is a crazy bloatware.The issues with documentation and similar things are all nonsense, it doesn't matters. Qt would be a decent framework due to its capabilities, but the amount of code and data that needs to be installed breaks all records - and that's terrible.

author: Simon
author_rank: Unknown
timestamp: March 16, 2025, 08:18:36 am
content: Well I am not so fussed about the size of the program itself although I should have bought a laptop with a bigger drive. Have you ever installed Atmel studio? I once had to write a manual for my boss on how to flash a chip and he would have to install Atmel studio to do this. I literally wrote in my instructions to go grab breakfast while it was installing as seriously, this would take 20 minutes.... And this is just for a micro controller, several GB.The documentation is nuts though. Certainly not aimed at beginners. I have gone back to the last tutorial I did and thought I'd look through the starter code they provide. No mention of a resource file to get the images to load and yet load they do. So I am confused. I followed the online PDF book and files would not load. At first I thought they were to come from Qt creator itself but the author made no mention I tried creating my own but nothing. I know the book was originally written for Qt 5 before being updated to Qt 6 and I have noticed some Qt 5 references so at this point I really do not know if the resource files are an old or new thing or if there are just many ways of doing the same things. This makes it difficult as I never know if my setup is what the materials expect me to have.

author: radiolistener
author_rank: Super Contributor
timestamp: March 16, 2025, 09:01:22 am
content: Quote from: Simon on March 16, 2025, 08:18:36 amIf you have plenty of disk space, you might not notice such problems. However, when a small GUI application fits into a 5-10 KB executable and works perfectly without requiring the installation of bloated libraries, and you try to rewrite it in Qt and realize it requires downloading hundreds of libraries totaling several gigabytes and unnecessarily bloats the application's code to tens of megabytes and adding dependency on gigabyte-sized libraries linked with specific version, it starts to get frustrating - even if you have plenty of disk space and your internet speed allows downloading gigabyte-sized libraries without worrying about time.And not to mention the issues with library versions. Take, for example, the Qt samples. Some of them you simply won't be able to compile, and if you do manage to compile them, they won't work due to library version issues. The need to modify the application code to make it compile with your version of Qt is quite common issue.For these reasons, I consider Qt to be bloatware, with the classic problem of versioning hell.

author: Simon
author_rank: Unknown
timestamp: March 16, 2025, 09:41:35 am
content: Yes the examples are useless, even the Qt academy tutorials seem to be out of date already.

author: DiTBho
author_rank: Super Contributor
timestamp: March 16, 2025, 09:55:30 am
content: Any container with QT dev ?It would be the perfect case

author: Nominal Animal
author_rank: Super Contributor
timestamp: March 16, 2025, 10:07:05 am
content: Qt signal (event source) and slot (event receiver function) mechanism is funky, but not crap. For one thing, it works across threads just fine.The documentation issue is that there are multiple ways of referring to these, and there are differences here between major versions of Qt. There are some significant differences in the details between minor versions, so being very anal about the version being referred to is important. Annoying, yes, but important. Are you using Qt 6.8 or some other version? I admit, I still prefer Qt 5 (5.12 to 5.18).Because the slots can be overloaded –– different handler for different parameters –– you need to specify the prototype for the target slot when connecting. If you use the string-based format (usingSIGNAL()andSLOT()macros), it will be resolved at runtime; the functor (aka function pointer) based format (using&Class::signalNameand&Class::slotName) is resolved at compile time.You'll also see a lot of C++ lambda functions that capture the context variables by value, using the format[=](){function body}.I avoid the mess by writing the code myself, and only using Qt Creator to provide me with the user interface description file. I do prefer theQUiLoader(XML) approach over theQML, though. Both can be used with Qt Creator, the trick is that you don't let it generate any UI C++ code for you; the initial skeletons only, perhaps.Automatic association of member functions to slots is based onQMetaObject::connectSlotsByName(), which looks at your main class, and connects any member functions namedon_objectName_signalNameto the signalsignalNameof UI object with nameobjectName. You do not have to use it, you can also do it yourself (connect(widget,&widgetClass::signalName,receiver,&class::method), withreceivertypically being the your main class instancethisyou do the connections in), for example when you have many objects with signals connecting to the same handler function.When I first started using Qt, Qt Creator confused many things. So, I did some UIs with my own code only, including creating the UI widgets at run time. This helped me understand the widget hierarchy, and later use Qt Creator to help with my workflow, instead of forcing me to the workflow the Qt Creator developers where thinking of when creating the tool.I can definitely relate to the frustration (even though not to the claim that this makes it utter shite), but I'd suggest doing some real (but not too complicated) UIs first in plain C++, perhaps on your workstation, avoiding Qt Creator, to understand how the toolkit works at the code level. It did that for me, at least. Then again, I have always used whatever time I needed to trulygrokthe thing, not respecting any deadlines others may have given me...

author: Simon
author_rank: Unknown
timestamp: March 16, 2025, 01:25:25 pm
content: Quote from: Nominal Animal on March 16, 2025, 10:07:05 amHow do you make a UI with just C++? my understanding is that the only way to go graphical is to use a toolkit/library of some kind.

author: Karel
author_rank: Super Contributor
timestamp: March 16, 2025, 02:57:05 pm
content: Quote from: ataradov on March 15, 2025, 09:33:34 pmWhat exactly is bad about their licensing? Qt is released as opensource with LGPL license,thus it can be used for free in closed source commercial software. Do you have a problem with that?

author: Simon
author_rank: Unknown
timestamp: March 16, 2025, 03:09:52 pm
content: Quote from: Karel on March 16, 2025, 02:57:05 pmWell can we rely on that statement of yours as legal advise? For someone like me coming at it from the perspective of never dealing with licensing before £4k is probably cheaper than the legal advice I should get and it includes support.Their small business package is a joke. As the main benefit of the license is the support and that is really all you are paying for. The small business license may sound attractive to a new company but if they are a new company they probably need support, but that is limited to 5 interactions per year.......

author: Karel
author_rank: Super Contributor
timestamp: March 16, 2025, 03:31:23 pm
content: Quote from: Simon on March 16, 2025, 03:09:52 pmhttps://en.wikipedia.org/w/index.php?title=GNU_Lesser_General_Public_License&useskin=vectorThe license allows developers and companies to use and integrate a software component released underthe LGPL into their own (even proprietary) software without being required by the terms of a strong copyleftlicense to release the source code of their own components.https://www.gnu.org/licenses/lgpl-3.0.html#license-textThe Qt group says so as well:https://www.qt.io/download-open-sourceSo, if the Qt group says that we can use Qt for free in closed source commercial software, who am I to deny it...

author: Nominal Animal
author_rank: Super Contributor
timestamp: March 17, 2025, 03:55:53 am
content: Quote from: Simon on March 16, 2025, 01:25:25 pmNo, I mean you don't use the Qt Creator to generate the C++ code for the user interface; you only use the XML or QMLdescription–– the XML or QML files –– of the interface, and write the necessary C++ code using Qt libraries yourself.Quote from: Simon on March 16, 2025, 03:09:52 pmLGPL 2.1 and later are explicit in that dynamically linking the library to a proprietary closed-source code does not create a derivative work.That is, when you use dynamic linking, and the user can replace the LGPL'd libraries, the situation is absolutely clear: you are explicitly allowed to use LGPL'd libraries from proprietary closed-source code.This means that for a Linux-based appliance, you do need to provide the users a way to replace the libraries, but you do not need to provide any sources for your own proprietary binaries.Using LGPL'd binaries in encrypted/protected firmware binaries the end user cannot modify, or statically linking LGPL'd binaries with proprietary closed-source code, is a different matter. The issue is the definition of "work that uses the library", with respect to copyright law. For the dynamic linking case, when the end user can replace the library, the situation is utterly clear. For the statically linked "lumped" model where the user cannot replace the library, the situation is iffy. That is all.Some background is in order. Qt Group Plc began as Trolltech in 1994 in Norway, but is now a Finnish company. The founders started writing Qt in 1991. They fundamentally understand GPL and LGPL licensing and the importance of GPL and LGPL to their business, especially throughKDE, K Desktop Environment. In the last five years or so, they've also made licensing much clearer on their website; before that, there was some marketing-wank trying to scare developers to get a commercial license, but it's much better nowadays.If your appliance documentation prominently tells that Qt is used for the UI under the LGPL license, and includes the exact versions and links to sources used, preferably with a way to rebuild the libraries from scratch (unless you use qt.io-provided binaries), and you abide by LGPL as I outlined above so users can replace those libraries, Qt Group Plc and Qt developers will be happy with you.One major issue some appliance developers have is that they want to encrypt the firmware so that end users cannot modify it. This is uncertain legal domain, and I claim it is incompatible with GPL (so Linux is out) and may be incompatible with LGPL. If you do encrypt the firmware, you need to provide the user with the encryption key so users can regenerate the firmware from GPL'd and LGPL'd sources and your proprietary binary blobs, so you'd have to use an unique key per appliance. With anything GPL-based like Linux, the fundamental idea is that the user owns the device, and must be allowed to do with it as they please, with only redistribution/copying restricted by the copyright laws and licensing. LGPL amends that in the sense that it allows proprietary code to use the library, but only when the user is in full control of the LGPL'd library. When you understand this viewpoint, you'll see that everything in GPL and LGPL suddenly makes sense.

author: JPortici
author_rank: Super Contributor
timestamp: March 17, 2025, 06:16:21 am
content: Quote from: Simon on March 15, 2025, 08:36:03 pmYes,all the problems you describe are bizarre. I second the recommendation of getting a book, as i was really struggling in the beginning. Luckily i had the beaglebone book that had examples in Qt for the GUI part that helped me getting started (but i wouldn't recommend it now, Qt 5 is on life support .. and that was maybe even using Qt 4.)Resource system is pretty easy to understand: Add the file to a qrc file (using the resource editor maybe, right click on qrc file in the IDE, select resource editor instead of plain text) and then reference it in the project using its path. Bonus is that you get the resources copied over, as they live inside the bynary file. Minus that you get the resources inside the binary file (adds to size, can't change without recompiling)There are things missing in the docs (mainly WTF do i do for styling? where the f are the references for the various elements you have to use in the style?) that are explained better in the forum, or in the wiki. But look at almost any other API Reference out there, Qt is probably the best.But the key is to keep things simple. If you think something is getting too convoluted, there is always another, simpler way to do it

author: Jeroen3
author_rank: Super Contributor
timestamp: March 17, 2025, 07:18:20 am
content: Quote from: Simon on March 15, 2025, 08:36:03 pmYou're probably frustrated by your own lack of knowledge about software architecture. GUI software is hard.But Qt really is one of the best gui frameworks around imho. At least you don't have to worry about pixels when laying out a form....I'm currently trying something in Winforms with C#, and Qt really is decades ahead.However, Qt does rely on the programmer having decent knowledge on how to apply design patterns, recognize the patterns Qt uses and fit the classes in their design.I recommend this to get started:https://refactoring.guru/design-patternsThere are also many web-based gui solutions around. Qt also has one. Go with care. Web based is extremely fragile and wild west.

author: radiolistener
author_rank: Super Contributor
timestamp: March 17, 2025, 10:16:02 am
content: Quote from: Simon on March 16, 2025, 01:25:25 pmHere is example with simple window and button OK:Code:// gcc -o test test.c -Wall -lX11#include <X11/Xlib.h>#include <X11/Xutil.h>#include <X11/Xos.h>#include <stdio.h>#include <stdbool.h>int main() {Display* display;Window window;XEvent event;int screen;display = XOpenDisplay(NULL);if (display == NULL) {fprintf(stderr, "Cannot open display\n");;return 1;}screen = DefaultScreen(display);window = XCreateSimpleWindow(display, RootWindow(display, screen), 100, 100, 300, 200, 1,BlackPixel(display, screen), WhitePixel(display, screen));XSelectInput(display, window, ExposureMask | ButtonPressMask);XMapWindow(display, window);GC gc = XCreateGC(display, window, 0, NULL);XSetForeground(display, gc, BlackPixel(display, screen));while (true) {XNextEvent(display, &event);if (event.type == Expose) {XDrawRectangle(display, window, gc, 100, 80, 100, 40);XDrawString(display, window, gc, 130, 105, "OK", 2);} else if (event.type == ButtonPress) {int x = event.xbutton.x;int y = event.xbutton.y;if (x >= 100 && x <= 200 && y >= 80 && y <= 120) {break;}}}XFreeGC(display, gc);XDestroyWindow(display, window);XCloseDisplay(display);return 0;}

author: Jeroen3
author_rank: Super Contributor
timestamp: March 17, 2025, 10:46:57 am
content: Quote from: Simon on March 16, 2025, 01:25:25 pmYou need the framework because it's anenormousamount of work to do layout and stuff.eg:https://github.com/nicbarker/clay

author: Simon
author_rank: Unknown
timestamp: March 17, 2025, 11:18:04 am
content: There are plenty of inconsistencies. Last night I sort of completed the tutorial on exposing C++ to QML. But this was not after having to delete what looked like some sort of background code that was auto generated in some file somewhere that was not mine. I suspect this was because first a project was compiled where a C++ class was created and an instance of it declared in the main qml file.Then the tutorial decides that now we will create a whole QML module of the UI items so that they can be duplicated. So substantial changes happen and I suspect that this recreates the same auto generated code for the class that now is an exact duplicate with errors for the redefinition of a variable that had nothing to do with me.So I deleted one of them and it worked. Well my layout is a mess but I'm not surprised as the tutorial really jumps around fast when it shows you what to copy and paste from one place to another without really showing you. So I'd say that I have done it. But there is no explanation as to what any of this is for. You are just told to do this, now do this and so forth. So I will sit down and go through the code myself and try and figure it out and write my own instructions.Some things that are shown don't match what I actually have as i guess the usual applies of different versions

author: Jeroen3
author_rank: Super Contributor
timestamp: March 17, 2025, 11:34:42 am
content: Quote from: Simon on March 17, 2025, 11:18:04 amQt uses ameta-object-compilationsince, well... C++ is still C and does not have any fancy language features C# and such have. So in order to get some things like,like signals and slotsfancy function pointers, or basicreflection, there is a need to auto-generate some code.Especially the translation from qml or .ui to something the c++ compiler understands is essential for GUI toolchains.I highly recommend you start research some C++, Qt and it's tool-chain before commencing with any other usage-tutorials if this is what you are struggling with.All beginning with new codebases is hard, because there are many unknowns and you may still think in wrong or old ways.edit: Oh and, use chatgpt or possiblecopilot. It read all the docs for you.

author: Karel
author_rank: Super Contributor
timestamp: March 17, 2025, 12:31:40 pm
content: I strongly recommend to stay away from QML and stick with the QWidgets only, at least until you have enough experience with Qt.https://doc.qt.io/qt-6/qtwidgets-index.htmlhttps://doc.qt.io/qt-6/examples-widgets.html

author: Simon
author_rank: Unknown
timestamp: March 17, 2025, 12:37:35 pm
content: Yes I get that the code in the background had to be created, I mean that is the point of using this thing. I have already had to sort out issues with the MOC system using a different naming convention to the refactor auto generate Q_PROPERTY functions.I suspect that because the class had been used in two different ways some background code had been generated twice. The tutorial over complicated things and should have done it one way or the other and not tried to do both at once. Or there is some bug in the auto generation which is easily fixed by deleting the duplicate, more likely a failure to clean up stuff. But if you are producing a tutorial, don't do it in a way that will cause your own system to fail.

author: Simon
author_rank: Unknown
timestamp: March 17, 2025, 12:39:45 pm
content: Quote from: Karel on March 17, 2025, 12:31:40 pmIs that future proof? or is the transition easy?

author: Jeroen3
author_rank: Super Contributor
timestamp: March 17, 2025, 01:07:02 pm
content: iirc qml does not do code-behind, which makes it un-intuitive for beginners.widgets does, which makes it an architecture trap for beginners.

author: Karel
author_rank: Super Contributor
timestamp: March 17, 2025, 01:55:20 pm
content: Quote from: Simon on March 17, 2025, 12:39:45 pmYes, it's future proof and there's no such thing as a transition. QML is an addition, not a replacement. QWidgets is what made Qt famous.

author: Simon
author_rank: Unknown
timestamp: March 17, 2025, 04:37:21 pm
content: Quote from: Jeroen3 on March 17, 2025, 01:07:02 pmCode behind?

author: Zipdox
author_rank: Regular Contributor
timestamp: March 17, 2025, 04:57:55 pm
content: Personally I prefer GTK3, partly because I use C and not C++. I don't know what your usecase is though. GTK has gresource for embedding resources in your program. A basic Makefile will get you started, no need for a complicated build system.

author: chilternview
author_rank: Frequent Contributor
timestamp: March 17, 2025, 05:46:24 pm
content: Qt's not so bad. I've been using it since 2.3.0, think that was about 25 years ago... I did look around when they bumped the license fee up by about 3x a few years ago, which was extortion, although you can get a 'small business' version for £500/year, unfortunately with that you don't get support. But then the support had degenerated from really, really good in the Trolltech days to fairly poor in recent years now Qt is run by men in grey suits.It does have a pretty steep learning curve, if you've never done gui programming before. I had previously used MFC which was truly horrible and illogical. Porting to Qt took a fraction of the time I expected as the API is quite logical and (at least in my opinion) the documentation is rather good. Yes some things are a bit obscure but there is a helpful community out there if you need it.The other nice thing is that apps can be relatively easily written that run on Windows, Linux and Mac, without #ifdefs everywhere. I still build from source rather than download the gigabytes of the official installation, that way I can cut out all the bloat like QWebengine etc that I don't care about. And I don't use QML - just raw Qt widgets to keep things lean and simple.

author: Simon
author_rank: Unknown
timestamp: March 17, 2025, 06:37:39 pm
content: To be honest I think widgets is as much of a mess. From a quick glance at some examples I think I prefer the QML way of doing things. Keep the graphics separate.

author: JPortici
author_rank: Super Contributor
timestamp: March 18, 2025, 05:58:23 am
content: It's C++, you can make a mess of it, or keep things clean. It takes experience of course.I like how easy you can expand/reimplement QWidgets, which should be one of the main points of any GUI framework: how easy it is to make new widgets, and how well they perform in contrast to native/internal ones. I loathed winforms/wpf (slow, writing is a mess) and old vb6 methods (writing really is a mess)

author: Jeroen3
author_rank: Super Contributor
timestamp: March 18, 2025, 06:38:09 am
content: Quote from: Simon on March 17, 2025, 04:37:21 pmYou doubleclick on a widget and go to the event function.

author: JPortici
author_rank: Super Contributor
timestamp: March 18, 2025, 09:48:12 am
content: Quote from: Jeroen3 on March 18, 2025, 06:38:09 amOh yes, it's "good" if you are a beginner and come from visual basic and the like, but the moment you want/need something a little different you get to deal with manual signal/slot (the problem being how to find the correct signal from the widget, from which base class)Also, i've been bitten more than once by the signal/slot association by name (rename a widget and stuff breaks) which is why they added a specific warning against it

author: JPortici
author_rank: Super Contributor
timestamp: March 18, 2025, 09:56:59 am
content: Quote from: Simon on March 17, 2025, 12:39:45 pmNothing is ever future proof in software development (unless maybe C90/C99)So, Transition easy. Though i recommend to stay on any LTS release (such as 6., every minor release (6.x) will add new stuff and some other stuff will be deprecated, usually for the best, and you may need to redeploy the library (and not just replace the executable). But it takes like ten minutes to check the differences. Every patch release will require zero updates (unless it fixes problems you had, so you can remove the workarounds)It's possible the minor release comes with an updated compiler, so check that as well, but i actually don't care. I stay with the LTS release.In fact, i stayed on 5.15.8 (last LTS release for Qt5) until Qt Creator 14 (which removed python 2, so couldn't work with the MinGW version that was shipped/played nice with Qt5) which gave me the extra push to migrate to Qt6, but overall many small changes in Qt6 made it even nicer to work with. I lost the ability to deploy 32bit binaries, but i don't care. First project took a day to figure out things, the remaining ones minutes.

author: voltsandjolts
author_rank: Unknown
timestamp: March 18, 2025, 10:03:59 am
content: I miss the speed and simplicity of Borland C++ 5 (from circa year 2000). It's installer is 80MB, installed size 220MB and still runs on Win10, but showing it's age. It would be great ifLazarus IDEalso suported C++, but alas, no. Maybe I should learn pascal!

author: Nominal Animal
author_rank: Super Contributor
timestamp: March 18, 2025, 10:06:19 am
content: Quote from: Simon on March 17, 2025, 06:37:39 pmEh?I use the Qt Creator to give me the QtWidget-based XML.uifile that I load/build with QUiLoader, part of the UiTools Qt module.The difference is that I use XML instead of QML, and I do not use QtQml or QtQuick at all.Unlike what Jeroen3 implied, you donotneed to let Qt Creator create the C++ code to instantiate the UI (so that double-clicking on the widget takes you to the generated C++ code handling the events related to that widget). That was exactly what I was recommendingagainst.I often augment the XML file with a signal-slot pairing information, so that I don't need to rely onQMetaObject::connectSlotsByName(), or need to write trampoline functions when a signal can be directly targeted to a slot of another object (instead of my own code).

author: chilternview
author_rank: Frequent Contributor
timestamp: March 18, 2025, 11:26:41 am
content: Quote from: Nominal Animal on March 18, 2025, 10:06:19 amMost (probably 95%) of my gui dialogs/widgets are made in Qt Designer, which spits out a .ui file; the rest are hand coded where e.g. you need to reimplement the paintEvent() of the widget.Then I subclass each ui class, and add in code for signals/slots and other stuff specific to that widget.Signals and slots connections can be defined in Qt Designer or in the subclass, whichever you prefer.I've not used QUiLoader, probably because it wasn't available at the time. Looks powerful though.

author: Nominal Animal
author_rank: Super Contributor
timestamp: March 18, 2025, 12:37:05 pm
content: Quote from: chilternview on March 18, 2025, 11:26:41 amI've used it since Qt 4. By default, if you name your slots (signal handlers) in your main class ason_ObjectName_SignalName, it will automatically connect the signals to your handlers via QMetaObject::connectSlotsByName.The same works for Python Qt, too. Seethis(usingthis) for a Python + Qt + XML Ui file example.

author: SiliconWizard
author_rank: Super Contributor
timestamp: March 18, 2025, 12:51:45 pm
content: Quote from: voltsandjolts on March 18, 2025, 10:03:59 amYou definitely should.

author: DiTBho
author_rank: Super Contributor
timestamp: March 18, 2025, 01:53:44 pm
content: Quote from: Jeroen3 on March 17, 2025, 07:18:20 amnice book, ordered!

author: Karel
author_rank: Super Contributor
timestamp: March 18, 2025, 01:54:53 pm
content: I never use QtCreator or QtDesigner and my Qt projects don't have *.ui files and it gives me ultimate freedom.Unfortunately, it's not something you learn overnight. Still, it's the best framework and it offers the best cross-platform experience.

author: DiTBho
author_rank: Super Contributor
timestamp: March 18, 2025, 01:56:36 pm
content: Quote from: Jeroen3 on March 17, 2025, 10:46:57 amclaylooks very interesting.

author: Simon
author_rank: Unknown
timestamp: March 18, 2025, 06:55:33 pm
content: https://doc.qt.io/qt-6/topics-ui.htmlLooks like they really want people to use Qt Quick. I will need to be ready for a touch screen requirement, they imply Widgets won't do this although I would have thought that a touch screen is basically a mouse. I assume the QT quick touchscreen reference is all about being able to do things like slide across a screen rather than just touch it for a click.

author: nctnico
author_rank: Super Contributor
timestamp: March 18, 2025, 07:42:48 pm
content: Quote from: Simon on March 17, 2025, 06:37:39 pmThat is a slippery slope. For some reason it is a holy grail sought after by some developers to keep the functions of the UI seperated from the layout. But it only makes sense if you are working on a program where you expect a vastly changing layout. In such a case you'll be developing something like a web browser or an application which is highly configurable by the user (let me get back to that later). Microsoft has had several of these kind of GUI / code detachment schemes but I don't think any of those has been very succesful as you'll typically need to use code to implement intelligent dynamic behaviour anyway.IMHO there is nothing wrong with defining widgets in code. It may seem tedious at first but it is much easier to place controls in a grid if you put the placement in a for loop and increment the X and / Y values compared to trying to do this with a point & click GUI designer (like the one used in Visual Basic). Bonus points for taking the size of the window into account. If you have a basic setup like this (it really consists of a few lines of code), you can copy and paste to create different 'screens' easely.To get back to decoupling logic and presentation: If you really want to decouple logic and GUI, consider using a web browser and integrate something like the Oatpp web framework in your code.

author: Simon
author_rank: Unknown
timestamp: March 18, 2025, 07:45:16 pm
content: I'll look into widgets.

author: Simon
author_rank: Unknown
timestamp: March 18, 2025, 07:52:29 pm
content: Although at this point is there any advantage to Qt widgets over say FLTK?

author: Nominal Animal
author_rank: Super Contributor
timestamp: March 19, 2025, 04:00:15 am
content: If you have a simple example case in mind –– say, like my Python + Qt + serial communications to an Arduino example I linked to ––, you could always suggest something. When you've worked with a tool for a longer time, it is difficult to devise a good "tutorial" case.I suspect that if someone still early in the learning curve were to suggest what kind of an example project they'd like to see, we might be able to come up with a good one together. Just sayin'.

author: JPortici
author_rank: Super Contributor
timestamp: March 19, 2025, 06:08:53 am
content: Quote from: Simon on March 18, 2025, 07:52:29 pmQt(6) takes care of very annoying things like DPI and per-screen DPI in a way completely transparent to the user. And many other simillar nuances that guarantee a consistent experience across Devices and OSes. Most frameworks completely suck for high dpi screens, android solves it by using "dip" units and translating them to pixels internally, but when it comes to the equivalent device independent text height... well, mantaining a consistent look in android, or even iOS for that matter, is impossible. Apple/google are trying really hard to get there.Multithreading is IMHO simpler than other threading libraries and platform specific details are taken care of.It guides you to use a particular subset of C++ that is easier to tame IMHOI honestly don't know where you are picking up they want you to use QML and QtQuick, if anything in the forum they are suggesting they want to get rid of them, especially QML, which can be a security nightmare according to some of the docs, but they are bound to keep some customers happy. I wonder if we'll see QML in Qt 7

author: Jeroen3
author_rank: Super Contributor
timestamp: March 19, 2025, 06:33:31 am
content: Quote from: Nominal Animal on March 18, 2025, 12:37:05 pmYeah it does this. Careful though, implicit stuff like this breaks your head when it somehow doesn't.Sometime ago they also introduced explicit connecting (typesafe) so you get compile errors when the function signatures don't match. Much better!Code:QObject::connect(&a, &Counter::valueChanged,&b, &Counter::setValue);

author: Simon
author_rank: Unknown
timestamp: March 19, 2025, 07:09:00 am
content: Well my current example would be a custom CAN bus data interpreter, read data off the CAN bus and put it on the screen in ways that make sense. Graphs, readouts, depending on the particular value. A dashboard I guess but with more detailed textual information for some stuff as you can't plot everything no would you want to.

author: Simon
author_rank: Unknown
timestamp: March 19, 2025, 07:10:43 am
content: Quote from: JPortici on March 19, 2025, 06:08:53 amJust read the stuff here:https://doc.qt.io/qt-6/topics-ui.htmlespecially in the comparison table it makes it sound like there is stuff only QML does. In forums I have read people saying that they are pushing QML because it is JavaScript and there are more JavaScript people around than C++ programmers so it's cheaper to hire them and give them something they can do.

author: Jeroen3
author_rank: Super Contributor
timestamp: March 19, 2025, 07:44:43 am
content: In correct architecture, the UI should be decoupled from the core code so you can run whatever UI. Or none at all, for testing.With Qt Widgets you can have some of the core code, if also made with Qt, such as models, seep into the UI code. You can also do it the other way around and snake your core code in the UI code.... (avoid this please)With web-stuff you have to create duplicate objects in the other language with translation code because it needs to sent to a browser over http(s).It has advantages, such as the ability for a polished ui (made by web frontend people) with fancy graphics or acceleration (opengl) for "Fluid animated UIs".It has disadvantages, such as that you have two distinct tech stacks.Do not underestimate how much time you're spending centering divs.

author: JPortici
author_rank: Super Contributor
timestamp: March 19, 2025, 08:28:21 am
content: Quote from: Simon on March 19, 2025, 07:10:43 amreally? It's not the impression i had. Guess i was reading different threadsAnd whatever QML brings to the table, i don't care about (gestures, animations, ...)at least not for my pc software (the animations I implement are fade in/out or page scrolling, nothing that can't be done in C++)Re: your endless canbus quest, I did that of course, canbus is nothing special on windows. My interface is from KVaser so i just added the dll and header files to the project. Include the header and call the functions. On linux, i don't know. Probably you need to use the QSerialBus classes? Also, don't know if you need to do anything special if you have an interface supported by QSerialBusThis is one of the few projects i haven't migrated to CMake as it's feature freeze right now. It's still using qmake (and it's easier to add library files there, as you can use the context menu)You can start single threaded then move the CAN stuff to a different thread. To get the data (available interfaces, data from the bus, ...) send a signal from the CAN stuff, a slot in the GUI element will receive the data and update the GUI. To set the data (select the interface, start, stop, configure, ...) you do the opposite, a signal from the GUI element is connected to a slot in the CAN stuff object.the .pro file looks like this:Code:QT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsCONFIG += c++17# You can make your code fail to compile if it uses deprecated APIs.# In order to do so, uncomment the following line.#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0SOURCES += \all my sourcesHEADERS += \all my other headerskvaser/canevt.h \kvaser/canlib.h \kvaser/canstat.h \kvaser/obsolete.h \kvaser/predef.h \FORMS += \mainwindow.ui \obdxconfigurationdialog.ui# Default rules for deployment.qnx: target.path = /tmp/$${TARGET}/binelse: unix:!android: target.path = /opt/$${TARGET}/bin!isEmpty(target.path): INSTALLS += targetDISTFILES += \kvaser/canlib32.dll \kvaser/canlib32.libwin32: LIBS += -L$$PWD/kvaser/ -lcanlib32INCLUDEPATH += $$PWD/kvaserDEPENDPATH += $$PWD/kvaserwin32:!win32-g++: PRE_TARGETDEPS += $$PWD/kvaser/canlib32.lib#else:win32-g++: PRE_TARGETDEPS += $$PWD/kvaser/libcanlib32.aFor example, to get the list of connected interfacesCode:MainWindow::~MainWindow() {if (canHandle >= 0) {canBusOff(canHandle);canClose(canHandle);}delete ui;}void MainWindow::loadCanInterfaceData(void) {canInitializeLibrary();//Initialize DatacanHandle = -1;int nChannels;canStatus status;ui->cbCanInterfacesList->clear();status = canGetNumberOfChannels(&nChannels);if (status == canStatus::canOK) {if (nChannels > 0) {for (int idx=0; idx<nChannels; idx++) {int deviceChannel;char deviceName;canGetChannelData(idx, canCHANNELDATA_CHAN_NO_ON_CARD, &deviceChannel, sizeof(deviceChannel));canGetChannelData(idx, canCHANNELDATA_DEVDESCR_ASCII, deviceName, sizeof(deviceName));if (!QString(deviceName).contains("Virtual", Qt::CaseInsensitive)) {ui->cbCanInterfacesList->addItem(QString("%1 - %2 Ch %3").arg(idx+1).arg(deviceName).arg(deviceChannel+1), idx);}}}}if (ui->cbCanInterfacesList->count() > 0) {ui->cbCanInterfacesList->setEnabled(true);ui->pbSelectCanInterface->setEnabled(true);}else {ui->cbCanInterfacesList->setEnabled(false);ui->pbSelectCanInterface->setEnabled(false);}}(but here i didn't do more than follow the examples that kvaser provided and adapted them to qt)

author: Simon
author_rank: Unknown
timestamp: March 19, 2025, 12:07:36 pm
content: Quote from: JPortici on March 19, 2025, 08:28:21 amit's not a case of an endless quest, I have not looked at the CAN bus side of things much other than to establish that in linux at least it is natively supported. One of the microchip CAN controllers on SPI has a driver for it in linux so I don't have to worry and have parked that there. The bigger aspect to anything I would want to do it putting stuff on the screen. Once those two are accomplished then I can move on to adding other functionality.

author: Nominal Animal
author_rank: Super Contributor
timestamp: March 19, 2025, 04:04:08 pm
content: You'll want to run your I/O and parser in a separate thread anyway –– UI thread is event-driven and "owned" by the UI toolkit; not the place you want to do any work or require low latencies ––, so I'd suggest you start by writing text-mode CANbus parser first.

author: Simon
author_rank: Unknown
timestamp: March 19, 2025, 05:56:56 pm
content: Yes, all that in time. If I don't have fancy graphics, there will be no product.

author: Jeroen3
author_rank: Super Contributor
timestamp: March 20, 2025, 07:17:18 am
content: Kvaser is very easy to implement in your own software. Their platform is very stable.There is a QCanBus, but it does not support kvaser right now. I don't think it's worth it porting it yourself, there don't seen to be other modules that depend on it.Anyway, at the end it's just message objects andobserver pattern.Let me know if you have any questions, all our qt based internal tooling uses kvaser leafs.

author: Simon
author_rank: Unknown
timestamp: March 20, 2025, 07:32:33 am
content: I have a kvaser adapter already so will use that in the first instance.

author: Nominal Animal
author_rank: Super Contributor
timestamp: March 20, 2025, 08:01:24 am
content: Quote from: Jeroen3 on March 19, 2025, 06:33:31 amYep, that's why I prefer to do my own connecting, using external information instead of implicit handler names.Typesafe (functor/function pointer) format as you showed is much better, definitely; I use it whenever possible. When using it with external UI files, one can look up the objects by name, but use the base class reference for the signal or slot involved, so that the UI can use any compatible subclass.To work all that out, I do prefer to create mock-ups in Inkscape or even HTML/browser,afterI have implemented the lower level functionality so I know for a fact which information I need, want, and may wish to display and let the user interact with. The base functionality is much more important to me than the UI. I often use Python for the UI because that way UI enhancements and modifications don't require recompiling, and Python is fast enough for this. All the proprietary logic is then in native binary libraries dynamically loaded by Python and interfaced usingPython ctypes built-in modulewith minimal Python glue; although it is much easier to interface library code written in C than that written in C++, I believe. Plus, that way I can license the Python UI part more permissively, so users who want can freely enhance the UI (including redistribute the Python parts, not including the proprietary libraries it needs), while keeping my proprietary bits private.

author: Geoff-AU
author_rank: Frequent Contributor
timestamp: March 21, 2025, 12:59:58 am
content: Quote from: Nominal Animal on March 18, 2025, 10:06:19 amThis is what I'm doing. Qt Creator to generate a .ui file and then a Python script that instantiates the UI. Picking up the functional hooks for events and so on was fairly intuitive for me, luckily. It's a very good separation of graphical UI creation and programming to do it this way.Quote from: Simon on March 19, 2025, 05:56:56 pmThis is where I feel the limitation is. Most controls available natively in Qt Creator look dated (25+ years old, classic buttons and text fields and numerical up/down etc). "LCD" value displays look particularly bad. There may be more modern options, I need to look. I used pyQtGraph because my app is Python. Charting/plotting with this library performs well even on a Raspberry Pi and looks beautiful.

author: SiliconWizard
author_rank: Super Contributor
timestamp: March 21, 2025, 01:03:46 am
content: You should use Pascal and Lazarus.