Creating a multitypes generic component



  • 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



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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.