Qt World Summit: Register Today!

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 :

  • @DavidM29 hi, You could have a QML Loader that will load the right control component.

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

Log in to reply