Results 1 to 6 of 6

Thread: QComboBox how far customizable?

  1. #1
    Join Date
    Apr 2008
    Posts
    39
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QComboBox how far customizable?

    Hi.

    A combo box has a view and a model. I can change the values for the roles of the item data (e.g. Qt::ForegroundRole).

    But how to make an item not selectable?

    I want to implement some kind of separator to categorize the entries in a combo box.

    Is that possible?

    Bye

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox how far customizable?

    Simplest way would be to insert "-----------" as data

    for the harder way, u can use delegates

  3. #3
    Join Date
    Apr 2008
    Posts
    39
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox how far customizable?

    I could insert a "-------------------", but it will still be selectable.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox how far customizable?

    Simply don't return Qt::ItemIsSelectable flag for that separator item.

    See QAbstractItemModel::flags().

  5. #5
    Join Date
    Apr 2008
    Posts
    39
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox how far customizable?

    Which means, that I have to implement my own model for that combo box?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox how far customizable?

    Quote Originally Posted by youkai View Post
    Which means, that I have to implement my own model for that combo box?
    I thought you already have one. In that case use QComboBox::insertSeparator() instead.

Similar Threads

  1. Editable QComboBox with QItemDelegate
    By Jmgr in forum Qt Programming
    Replies: 11
    Last Post: 10th December 2008, 09:21
  2. QDataWidgetMapper and QCombobox
    By miraks in forum Qt Programming
    Replies: 4
    Last Post: 6th December 2008, 17:53
  3. QComboBox - Few virtual methods
    By gruszczy in forum Qt Programming
    Replies: 17
    Last Post: 16th July 2008, 16:08
  4. QComboBox drop list button events
    By maird in forum Qt Programming
    Replies: 5
    Last Post: 20th October 2007, 19:25
  5. using QComboBox as an ItemView
    By EricTheFruitbat in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2007, 16:14

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
  •  
Qt is a trademark of The Qt Company.