Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Creating a multitypes generic component
Forum Updated to NodeBB v4.3 + New Features

Creating a multitypes generic component

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 598 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.
  • D Offline
    D Offline
    DavidM29
    wrote on 16 Jul 2018, 10:33 last edited by
    #1

    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

    O 1 Reply Last reply 16 Jul 2018, 13:07
    0
    • D DavidM29
      16 Jul 2018, 10:33

      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

      O Offline
      O Offline
      ODБOï
      wrote on 16 Jul 2018, 13:07 last edited by
      #2

      @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
      1
      • D Offline
        D Offline
        DavidM29
        wrote on 16 Jul 2018, 13:30 last edited by
        #3

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

        1 Reply Last reply
        0

        1/3

        16 Jul 2018, 10:33

        • Login

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