ListView draws each item on top of each other. What am I doing wrong?
Solved
QML and Qt Quick
-
wrote on 28 Feb 2019, 11:10 last edited by
Below code produces list view as shown in the screenshot. Probably I'm missing something very trivial but I can't figure out what?
import QtQuick 2.0 ListModel { ListElement { flag: "us" name: "USA" strength: "5" } ListElement { flag: "fr" name: "France" strength: "4" } ListElement { flag: "nl" name: "Netherlands" strength: "2" } }
import QtQuick 2.9 import QtQuick.Window 2.2 Window { visible: true width: 640 height: 480 Component { id: countryItem Item { Text { text: name + " " + flag + " " + strength } } } ListView { anchors { fill: parent } model: TestModel{} delegate: countryItem } }
-
Below code produces list view as shown in the screenshot. Probably I'm missing something very trivial but I can't figure out what?
import QtQuick 2.0 ListModel { ListElement { flag: "us" name: "USA" strength: "5" } ListElement { flag: "fr" name: "France" strength: "4" } ListElement { flag: "nl" name: "Netherlands" strength: "2" } }
import QtQuick 2.9 import QtQuick.Window 2.2 Window { visible: true width: 640 height: 480 Component { id: countryItem Item { Text { text: name + " " + flag + " " + strength } } } ListView { anchors { fill: parent } model: TestModel{} delegate: countryItem } }
hi @tapirath
give your countryItem -component a height, and preferably a width as well and you should be fine -
wrote on 28 Feb 2019, 11:33 last edited by
Works perfectly thanks
2/3