Results 1 to 10 of 10

Thread: QComboBox roles question

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: QComboBox roles question

    Where model/view convention explains this?
    noboro was right. You can look into the source, at line 808.
    ~ We are nothing in this universe ~

  2. The following user says thank you to viulskiez for this useful post:

    mentalmushroom (27th April 2012)

  3. #2
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: QComboBox roles question

    Thanks, guys. Now it's clear, but how can I change this behavior?

  4. #3
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: QComboBox roles question

    I suggest to subclass QStandardItem then set it as item prototype (QStandardItemModel::setItemPrototype).
    ~ We are nothing in this universe ~

  5. #4
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QComboBox roles question

    You could try using a delegate. Something like this:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. class Delegate : public QStyledItemDelegate
    4. {
    5. QString displayText(const QVariant &value, const QLocale &locale) const{
    6. return QString("item %1").arg(value.toString());
    7. }
    8. };
    9.  
    10. int main(int argc, char *argv[])
    11. {
    12. QApplication a(argc, argv);
    13. QComboBox comboBox;
    14. comboBox.setEditable(true);
    15. for (int i = 0; i<5; ++i){
    16. comboBox.addItem(QString("%1").arg(i));
    17. }
    18. comboBox.setItemDelegate(new Delegate);
    19. comboBox.show();
    20. return a.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Qcombobox and model/item based question
    By yaguis in forum Newbie
    Replies: 5
    Last Post: 7th June 2010, 01:22
  2. Getting all roles of specified column and/or model
    By NoRulez in forum Qt Programming
    Replies: 0
    Last Post: 29th April 2010, 11:21
  3. QSqlQueryModel + user defined roles
    By NoRulez in forum Qt Programming
    Replies: 1
    Last Post: 7th December 2009, 07:29
  4. Basic question on QComboBox
    By Raccoon29 in forum Newbie
    Replies: 2
    Last Post: 9th May 2008, 16:41
  5. Language Selector QCombobox question
    By MarkoSan in forum Qt Programming
    Replies: 5
    Last Post: 31st January 2008, 08:03

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.