Results 1 to 5 of 5

Thread: QComboBox: disabling an item in the combobox menu

  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default QComboBox: disabling an item in the combobox menu

    Hi,

    Is there an easy way to disable some of the items(or row data or whatever) in the combobox's menu when one of them is selected?

    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox: disabling an item in the combobox menu

    I don't understand what 'disabling' in this context means... the item is in the list, so what would "disabling" it do exactly?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QComboBox: disabling an item in the combobox menu

    You can create a custom item delegate and react on some user data to paint some items in lighter grey (or wathever) and make it so you can't select them.
    How this will work with editable comboboxes... I don't know.
    You probably want to subclass QComboBox too to alter the behaviour of the signals and slots with respect to those disabled items.

    A better way would be to just remove those items from the list.

  4. #4
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QComboBox: disabling an item in the combobox menu

    @high_flyer: it means they can be seen in the menu when the combobox clicked but somehow can't be selected by users. I wonder the somehow part..ok now?

    @tbscope: I wish I could remove them, but it won't work for me. I think they should be seperate classes so that they can be modified in an agile way just like QListWidget item.

    Maybe css solve the problem which I don't think so.

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox: disabling an item in the combobox menu

    I too think that the proper way is through a custom delegate.
    CSS or style sheets will only change the look and feel but not the behaviour.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Add close button in In Combobox item.
    By akram.halder in forum Qt Programming
    Replies: 2
    Last Post: 12th August 2010, 12:09
  2. Disabling options in a combobox
    By the goat boy in forum Qt Programming
    Replies: 3
    Last Post: 21st July 2008, 18:37
  3. combobox and item colors
    By zorro68 in forum Qt Programming
    Replies: 16
    Last Post: 23rd September 2007, 12:54
  4. Retrieve userData of a comboBox item
    By jiveaxe in forum Newbie
    Replies: 6
    Last Post: 23rd August 2007, 10:28
  5. Can Qtable Item be a comboBox?
    By iGoo in forum Qt Programming
    Replies: 2
    Last Post: 4th August 2006, 09:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.