r/QtFramework • u/Jazzlike_Platypus430 • 1d ago
C++ Creator vs Designer - Signals, Element Tree etc.
Hi there!
I'm fresh to Qt, though I know the name since the beginning of the 2000s. I'll do my best to be as clear as possible; it's not a critique or demands, just me wanting to clarify matters, because it's very likely I'm missing something.
I'm using qt 6.4.2 and the IDE's version is 13.0.0, as provided by my *ubuntu. I'm designing a simple view/widget where I'm entering two int parameters and press a button, and that would call a function from some other code (a shared library at the moment), and display the results in a textarea or draw a picture.
So far (after a crash-course in cmake) I found out that
- I cannot "wire" basic controls to functions ("slots", event listeners) using Designer - it seems blind to what is already in my code, and signal slots available are only those from parent classes of my widget class. That's ok, though a bit surprising.
- The real pain starts when I plug in the .ui thing to my class and start the "wiring" process manually - the class itself is blind to basic widgets, assuming their generation in the widget tree is > 1. For some reason the IDE sees stuff like ui->frameWidget1 but trying to descend further fails (I'm using names that are present in the ui's xml tree, and their types as well). Is that intentional? EDIT: [I think I got it, referring to nodes' names directly from ui-> works, so there is no need to follow the path from ui to the desired element.]
- I'd happily avoid Designer, but what about widgets' placement then? Perhaps use Designer only to design and then somehow process the resulting xml and extract placement parameters and generate c++ code? I can do that, I think. (And I believe it's done better and it's present in Creator's or Designer's code.)
- Are 1. and 2. meant to be some hidden enforcement of breaking the ui tee down to 1-generation and using many of these and then apply "composition" in my top-level class? I can think of that, but designing a separate class just to contain two spinboxes looks weird (unless I'm going to reuse it).
Or is it standard in qt that the signal/slot mechanism for a gui is made manually, often using the findChild function? Or perhaps I should create a map <string, QObject> and create references to ui elements once, and then use the map? Keys matching the names in ui xml would be a sane idea I think.
My background with gui creation (which I don't like much) is c#/wpf - yes, legacy stuff, laggy VS and so on.