Results 1 to 6 of 6

Thread: Enable sorting in QComboBox

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Posts
    13
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Enable sorting in QComboBox

    Hello.

    I have my own class derived from QAbstractTableModel. When I'm select a column in QTableView header font is going to be bold. I try to play with Qt::FontRole for headerData() function, but this is not avoid font to be bold. Any idea how to do it?

    Main problem is how to enable sorting in QComboBox. I have proxy model (with source from that QTableModel) which make behaviour like QListView for QComboBox. For this proxy I overwrite lessThan() function, but QComboBox in function view() return pointer to QAbstractItemView which do not have setSortingEnabled() (QListView do not have to). How to use lessThan function to sorting this proxy model?

    Many thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Enable sorting in QComboBox

    Is the proxy a QSortFilterProxyModel?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2008
    Posts
    13
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Enable sorting in QComboBox

    Yes, it is.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Enable sorting in QComboBox

    And what happens if you call sort() on it?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    kazek3018 (14th February 2011)

  6. #5
    Join Date
    Dec 2008
    Posts
    13
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Enable sorting in QComboBox

    Thanks it's working (I should got break).

    How to avoid bold font in QTableView when an item is selected?

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Enable sorting in QComboBox

    Render the header yourself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QML dropshadow, how to enable it?
    By technoViking in forum Qt Quick
    Replies: 1
    Last Post: 2nd November 2010, 23:21
  2. QTableView enable
    By Daxos in forum Newbie
    Replies: 1
    Last Post: 30th June 2010, 08:47
  3. Help need for sorting elements in QCombobox
    By narendra in forum Qt Programming
    Replies: 2
    Last Post: 6th January 2010, 07:48
  4. enable all Tooltips
    By clive in forum Qt Programming
    Replies: 3
    Last Post: 2nd January 2008, 12:08
  5. Qt4.1.1: Sorting QCombobox entries
    By Byngl in forum Qt Programming
    Replies: 4
    Last Post: 17th March 2006, 10:02

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.