I am trying to use rich text in a QComboBox but it does not support it. Perhaps I should write a subclass? But I am unsure on what I would need to override as I have never done anything like this before. Please help. Thanks!
I am trying to use rich text in a QComboBox but it does not support it. Perhaps I should write a subclass? But I am unsure on what I would need to override as I have never done anything like this before. Please help. Thanks!
Well, you have just to write your own item delegate with a proper paint method. For drawing rich text see QTextDocument. Then set the delegate to your box using QComboBox::setItemDelegate().
Thanks for the reply! I am unsure what you mean by delegate and wouldn't know how to add rich text using the QTextDocument. Could you please elaborate. Thank you.
For delegate see QComboBox::setItemDelegate() and read about Qt's Model/View Programming.
For rich text: Use QTextDocument read in the docs about Rich Text Document Structure. After you set your document up use QTextDocument::drawContents() to draw the content in your QAbstractItemDelegate::paint() method.
Bookmarks