I want to customize a listview in Qt, can anyone provide me some example or hints of how to do it? I am new to Qt.
You can apply stylesheet to your QListView
.
Check out here for the Qt documentation of customizing QListView
using stylesheets.
If you're using a standard item model or a QListWidget (or any other model that uses QStandardItem), you can set appearance properties on the items using setData.
So, The following will add a red item to a list widget:
QListWidgetItem *colorItem = new QListWidgetItem("Red");
colorItem->setData(QBrush(QColor(Qt::red)), Qt::ForegroundRole);
list.addItem(colorItem);
For a working code example and more detailed explanation, please see: http://ynonperek.com/qt-mvc-customize-items
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With