I can't find any way to put a line between items in my list. Am I missing something?
4
votes
2 Answers
14
votes
A style sheet would be easiest, for example:
myListWidget->setStyleSheet( "QListWidget::item { border-bottom: 1px solid black; }" );
You'll want to look at some of the style sheet documentation
1
votes
2 improvements to the accepted answer:
- Use the color palette of the widget to achieve a uniform look across different systems.
- It is necessary to restore the
item:selected
style when restylingitem
E.g. like this:
const auto & palette = tableWidget.palette();
tableWidget.setStyleSheet(QString("QListWidget::item { border-bottom: 1px solid %1; } QListWidget::item:selected { background-color: %2; color: %3; }")
.arg(palette.midlight().color().name(),
palette.highlight().color().name(),
palette.highlightedText().color().name()));
Here you can see that the separator lines and selection color fit the default style of the widget: