开发者

How to customize a listview in Qt

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.开发者_如何学C


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜