Connection different .ui in just mainwindow.cpp
-
Hi all!
I'm new here, I need your help.
I'm trying to connect different file .ui in a same mainwindow.cpp but obviously I need to set different name for ui.label. and so on. What can I do? Class declaration in each file?
I would use the label present in document_interface.ui in the file mainwindow.cpp.
I would need this because I would implement a State Machine in just one file (mainwindow.cpp) to make the SM itself more readable and clear. SM is required by vendor.!
Thanks,
Stefy
-
Hi and welcome to devnet,
What will that state machine do ?
How is it related to your widgets ? -
@SGaist The SM jump from a state to another one with different action like pushing on a button. Related to each state there is a different screen window projected on a display. I would need different .ui to manage textlabels and images on display.
Here a code of initial screen:
Thanks,
Stefy
-
And where is that state machine located ?
-
@SGaist It is located in MainWindow.. and I would like (if possibile), keep all the SM in this file and try to include the different .ui label in this file. My problem is just how to connect the label of different .ui in the MainWindow (what to declare and include in this file)
-
So you have different widgets each with a corresponding .ui file ?
If so, where are these widget created ? Also in your MainWindow ? -
@SGaist Yes, as you can see in the image, the different .ui are located in Forms. Each .ui is linked to its .cpp. What I would like to do is link all this forms (different architecture .ui with different QLabel) in the mainwindow.cpp --> use the different QLabel belonging to different .ui in the mainwindow.cpp
-
In that case, you should add proper APIs to these widgets rather than trying to access their internal state. This will have the side effect to reduce drastically the maintenance cost.
-
@Stefy said in Connection different .ui in just mainwindow.cpp:
And how can I do to add API?
Simply add public methods to your widget classes which allows other object to communicate with them.