Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Creating a multitypes generic component

    QML and Qt Quick
    2
    3
    359
    Loading More Posts
    • 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.
    • D
      DavidM29 last edited by

      Hello,

      I would like to make a multitypes component.
      What I mean by that is for example an option component which can have multiple value type.
      My option can be boolean, it can be a set of value, it can be a string...

      I would like to make a generic option component.
      I thought about making a Option component with an enum that allow to switch between checkbox, combox, textfield or other.
      But I don't know how to realize it.
      I don't have any idea how can I handle multi type value and give it to the right element.

      Should I add a property for each type and set the right property when I create an instance of my component ?

      I'm not sure to be very clear here is an example :
      0_1531737121240_7b255a2c-0849-48e8-bcea-5e8d98d21cae-image.png

      ODБOï 1 Reply Last reply Reply Quote 0
      • ODБOï
        ODБOï @DavidM29 last edited by

        @DavidM29 hi, You could have a QML Loader that will load the right control component.
        http://doc.qt.io/qt-5/qml-qtquick-loader.html

        1 Reply Last reply Reply Quote 1
        • D
          DavidM29 last edited by

          Thank you ! I'll have a look at it I have never seen this before.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post