Qt6 topics merged with General

Different styles of items in QListWidget

  • Is it possible to set different styles (via stylesheets) for different items in a QListWidget? Basically, I have two kinds of items, one kind with a custom widget inserted by QListWidget::setItemWidget, and another - plain items with text and icons. I would like to apply two distinct styles to them (not to customs widgets within items on one kind - they are already styled properly). I have found that QListWidgetItem does not have an object name, so I do not know how to differentiate two kinds of items in a stylesheet.

  • maybe "this stylesheetdelegate":http://qt-project.org/forums/viewthread/166
    can help

  • Thank you for suggestion, it is an interesting component which may be useful for another part of my work. As for this particular case, I have found it easier to use custom widgets in both kinds of items. I do not have a model and I simply use QListWidget as a (relatively) convenient container.

Log in to reply