Results 1 to 4 of 4

Thread: QAbstractItemView

  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 QAbstractItemView

    Hi,

    I wonder is it possible to give a fixed text color for examle for the 2nd item in a QComboBox? I tried up to;

    QAbstractItemView{ color: gray};

    but obviously there is no specific item number above as you see, which I exactly want.

    Thanks in advance.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 162 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QAbstractItemView

    using code you can do that; you could use a proxy model for example

  3. #3
    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: QAbstractItemView

    Hi again,

    Can you be a bit more specific if you don't mind?

  4. #4
    Join Date
    Jul 2009
    Posts
    139
    Thanks
    13
    Thanked 59 Times in 52 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QAbstractItemView

    This seems to work:
    Qt Code:
    1. cb->addItem("Red");
    2. cb->addItem("Gray");
    3. cb->addItem("Green");
    4. cb->setItemData(0, Qt::red, Qt::ForegroundRole);
    5. cb->setItemData(1, Qt::gray, Qt::ForegroundRole);
    6. cb->setItemData(2, Qt::green, Qt::ForegroundRole);
    7. cb->setItemDelegate(new QStyledItemDelegate);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 2
    Last Post: 26th February 2009, 10:12
  2. Need help getting QAbstractItemView syntax correct
    By Hookem in forum Qt Programming
    Replies: 3
    Last Post: 4th December 2008, 09:34
  3. Subclassing QAbstractItemView
    By psih128 in forum Qt Programming
    Replies: 4
    Last Post: 13th October 2008, 07:32
  4. QAbstractItemView
    By defumar in forum Newbie
    Replies: 9
    Last Post: 22nd January 2008, 13:50
  5. setContentsMargins in QAbstractItemView
    By Promethee in forum Qt Programming
    Replies: 2
    Last Post: 4th February 2006, 14:40

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.