Unsolved Adding custom properties to the QStackedWidget pages
-
Hi guys,
I'm preparing a custom widget based on the QStackedWidget and I need to add properties to each of the pages added to the StackedWidget. When I use Q_PROPERTY the properties are obviously added to the StackedWidget itself and not to its pages. I need this because I have to assign different properties values to different pages and I have to do everything design-time in QTCreator.
What I can imagine is ...- there is a way I don't know to specify custom properties for the added pages in the custom QStackedWidget
- there is a way I don't know to add (design-time) custom pages (qwidgets) in wich I have already added the needed properties
- there are probably (hopefully) other ways to reach the result I need ...
Thanks in advance for your support !
-
Hi
1:
Well Design Time you can use dynamic properties in Designer
Pressing the green + allows adding a property to the pages of the stacked.
Just select it in the list above the properties.2:
Yes but each must be added one by one so if you have many, it's a bit tedious.3:
Well Design time properties can be dynamic properties or you would need to make a full-blown
custom widget that integrates with Designer and adds a special type of pages that has the needed propertiesWhat do you need these properties on the pages for ?
You could add a special QWidget custom class that you use for the pages. This Widget would then pr default have the properties.
and then use the Creator promote feature on each page to make them from the plain Widget to your type widget.
But the properties won't be visible design time. only runtime. -
Thanks mrjj for your reply.
What I need is exactly what you wrote: "... a full-blown custom widget that integrates with Designer and adds a special type of pages that has the needed properties ". I'm preparing custom widgets to build display interfaces for automatic machines; each custom stackedwidget will represent a pages chain (a pages chain for the machine settings, one for the recipes, one for the results, one for input/output signals and diagnostics, ...).
In this context it may happen that in a pages chain some page shouldn't be visible depending on a machine setting or on a specific machine status. Basically I'd like to drop my custom stackedwidget on the form, add on it as many pages as I need, place on each page the widgets I need and define for each page (writing this info in a property) on which machine variable depends the visibility of that page. Another property I need is the variables refresh time for each page (a setting page could be refreshed every 500ms, a result page every 100/200ms, a diagnostic page every may be 50ms or less ...). For these reasons the custom pages properties (at the end their number will be around 10) have to be available in the designer.
Thank you and have a nice week-end ! -
@Vittorio61
Hi
Well, the dynamic properties will allow it, but not predefined, you would have to add them to each page.If you want this to be fully integrated then you must write a Designer plugin handling your StackedWidget
and its special pages.Ala this
https://doc.qt.io/qt-5/qtdesigner-customwidgetplugin-example.html
just a bit more complicated as you want the pages properties also to be surfaced and
i think you can flag them as such but not sure if its automatically.Do note if you are on windows platform, you MUST use visual studio as Creator is compiled with that
and plugins are DLLS.
SO on windows, you must use the same Qt version and compiler as shown in the About Creator.