Results 1 to 4 of 4

Thread: QComboBox styling

  1. #1
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Lightbulb QComboBox styling

    Hi, everyone.
    So, recently I got a problem. I can't find the way to make every QComboBox item has its own style. It's possible to change styles for the whole widget, but not for separate items. If anyboby knows a solution, please help me.
    I need something like this one http://www.innovasys.com/products/co.../overview.aspx.
    Even simplier, I only need to change color of item's text, its background and select different font styles (bold, italic, etc).
    Oleg Shparber

  2. #2
    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 styling

    You can make a custom model and use it instead of default QComboBox model.

  3. #3
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: QComboBox styling

    Thanks, but is there any other variants? I think it'll take a lot of time to implement new model. Or maybe there are examples how to make this?
    Oleg Shparber

  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 styling

    Quote Originally Posted by Oleg View Post
    I think it'll take a lot of time to implement new model.
    It only seems to be hard, but once you make your first custom model, it will be easy.

    Quote Originally Posted by Oleg View Post
    Or maybe there are examples how to make this?
    You can experiment with QStandardItemModel if you don't want to subclass anything. Although in long term it might not be the best solution. The other way is to create your own custom model by subclassing QAbstractListModel (there are instructions in the docs how to do it). You will also need a custom delegate that understands rich text (AFAIR you can find one somewhere on our site).

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

    Oleg (26th November 2007)

Similar Threads

  1. QComboBox drop list button events
    By maird in forum Qt Programming
    Replies: 5
    Last Post: 20th October 2007, 19:25
  2. QComboBox in QTableWidget : display troubles.
    By Nyphel in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2007, 23:29
  3. Styling a QComboBox
    By Enygma in forum Qt Programming
    Replies: 6
    Last Post: 23rd August 2007, 10:22
  4. using QComboBox as an ItemView
    By EricTheFruitbat in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2007, 16:14
  5. QDataWidgetMapper <=> QComboBox best practice
    By saknopper in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2007, 10:50

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.