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. Disable or hide elements in comboBox
Forum Updated to NodeBB v4.3 + New Features

Disable or hide elements in comboBox

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 2.6k 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.
  • RomanoFXR Offline
    RomanoFXR Offline
    RomanoFX
    wrote on last edited by
    #1

    Hi,

    I have a comboBox with a model (QStringList)

    From C++ side :

    comboModel << "toto" << "gogo" << "jojo" << "coco" << "zozo" << "dodo";
    

    In QML side, I just want display all the item but two (coco and zozo) in a comboBox in keeping the real index.

    Like that :
    toto (idx 0)
    gogo (idx 1)
    jojo (idx 2)
    dodo (idx 5)

    Is it possible ?

    Thank you

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi!

      Is it possible ?

      I don't think so.

      1 Reply Last reply
      1
      • RomanoFXR Offline
        RomanoFXR Offline
        RomanoFX
        wrote on last edited by
        #3

        Hi Wieland,

        Thank you for your answer.
        Should I do a model from QAbstractListModel and enumerate all elements? (role text and value/index) or it is better to insert an enum?

        Thank you

        ? 1 Reply Last reply
        0
        • RomanoFXR RomanoFX

          Hi Wieland,

          Thank you for your answer.
          Should I do a model from QAbstractListModel and enumerate all elements? (role text and value/index) or it is better to insert an enum?

          Thank you

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @RomanoFX Well, you can have a nice solution which will involve a little more effort or you can make it quick and dirty (maybe with some Javascript inside QtQuick). What are actually doing here? What's the purpose of the model and what are the indices needed for?

          1 Reply Last reply
          1
          • RomanoFXR Offline
            RomanoFXR Offline
            RomanoFX
            wrote on last edited by
            #5

            @Wieland Thank you for your answer. I really don't want doing it quickly and dirty :)

            An instrument got a configuration (binary file) and an array defines the kind of channel type (voltage, current, etc..) as an enum.
            So we take the enum, save it, and display the corresponding text with a QStringList.

            the enum : Voltage, current, pwm, thermocouple, counter
            BUT, some channels only do voltage , current and thermocouple. That's why I would keep the index of that enumerate.

            Please tell me if I am not clear.
            Thank you

            1 Reply Last reply
            0
            • RomanoFXR Offline
              RomanoFXR Offline
              RomanoFX
              wrote on last edited by
              #6

              I will do the first solution.
              Thanks

              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