Results 1 to 3 of 3

Thread: ComboBox of bmp:s

  1. #1
    Join Date
    Mar 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default ComboBox of bmp:s

    I am trying to get a delegate with a combobox of bmp:s to work in a qtablewidget.

    My problem is QVariant. I can get the combobox to work with strings, int, double...but not with a QIcon.

    It is not possible to do it this way, since QVariant dont take a QIcon.

    Qt Code:
    1. QIcon icon(QPixmap("./icons/check.bmp"));
    2. item1->setIcon(icon);
    3. item1->setData(Qt::EditRole, QVariant(icon));
    To copy to clipboard, switch view to plain text mode 

    and in the delegates setModelData...

    Qt Code:
    1. ComboBox *comboBox = static_cast<ComboBox*>(editor);
    2. int pos = comboBox->currentIndex();
    3.  
    4. QIcon icon = comboBox->itemIcon(pos);
    5. model->setData(index, icon, Qt::EditRole);
    To copy to clipboard, switch view to plain text mode 

    How can I solve this?

  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: ComboBox of bmp:s

    Use Qt::DecorationRole instead of Qt::EditRole.

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

    arturo182 (1st June 2009)

  4. #3
    Join Date
    Mar 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: ComboBox of bmp:s

    Thank you very much wysota...

Similar Threads

  1. [Qt 4.3.1]A problem with combobox style
    By Tamara in forum Qt Programming
    Replies: 3
    Last Post: 19th September 2007, 10:49
  2. Replies: 8
    Last Post: 15th May 2007, 09:21
  3. Combobox Signals
    By b1 in forum Qt Programming
    Replies: 3
    Last Post: 1st August 2006, 10:21
  4. Filling combobox from database
    By Philip_Anselmo in forum Qt Programming
    Replies: 3
    Last Post: 11th May 2006, 17:53
  5. table with combobox cells
    By mgurbuz in forum Qt Programming
    Replies: 2
    Last Post: 10th May 2006, 12:12

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.