Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Adding custom properties to the QStackedWidget pages
Forum Updated to NodeBB v4.3 + New Features

Adding custom properties to the QStackedWidget pages

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 529 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vittorio61
    wrote on last edited by
    #1

    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 ...

    1. there is a way I don't know to specify custom properties for the added pages in the custom QStackedWidget
    2. there is a way I don't know to add (design-time) custom pages (qwidgets) in wich I have already added the needed properties
    3. there are probably (hopefully) other ways to reach the result I need ...
      Thanks in advance for your support !
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      1:
      Well Design Time you can use dynamic properties in Designer
      alt text

      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 properties

      What 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.

      1 Reply Last reply
      3
      • V Offline
        V Offline
        Vittorio61
        wrote on last edited by
        #3

        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 !

        mrjjM 1 Reply Last reply
        0
        • V Vittorio61

          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 !

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved