I want to make listview design format
-
I want to draw listview design like this.
I m considering using QML or normal form..I draw listview and It's hard to make same form my pic.
-
I want to draw listview design like this.
I m considering using QML or normal form..I draw listview and It's hard to make same form my pic.
-
@darongyi Looking at your requirement, IMO, the best way would be to use QListView with custom delegate by subclassing
QStyledItemDelegate
and overridingpaint()
.
Or If using QML then following example may help you:import QtQuick 2.4 Item { width: 100 height: 120 ListModel { id: model ListElement { name: "W"; number: "3,000" } ListElement { name: "V"; number: "150" } ListElement { name: "A"; number: "20" } } ListView { anchors.fill: parent model: model delegate: Rectangle { width: parent.width height: 40 Row { anchors.centerIn: parent Rectangle { width: 60; height: 40; Text { color: index==0 ? "blue": "darkgray"; font.pointSize: 14; anchors.verticalCenter: parent.verticalCenter; anchors.right: parent.right; text: number } } Rectangle { width: 40; height: 40; Text { color: "lightgray"; anchors.centerIn: parent; text: name } } } } } }
You can added another
Rectangle
with withheight
as1
for separator between each Item. -
I made code and class.
I wrote on my blog. Check It out!