Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Disable the combo box specific item
Qt 6.11 is out! See what's new in the release blog

Disable the combo box specific item

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 631 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.
  • I Offline
    I Offline
    IknowQT
    wrote on last edited by
    #1

    Is there a way to disable a specific item in the combo box?

    For example, there is a combo box containing items from 1 to 5. I want to limit the items that can be selected according to the permission

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What comes to mind:

      • Use a QSortFilterProxyModel on top of a QStringListModel and filter out the values the person cannot select
      • Use a custom model where you re-implement the flags

      The first avoids to show "invalid values" to your user (asking why can't I select them ?).
      The second should do what you original want at the risk of your users wondering why there are unelectable items in a control which should offer them only valid choices.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

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