[Solved] Positioning ListView within Grid
-
@Aros No. They are not overlayed.
Component { id: delegateInstance Item{ width: parent.width; height: 40 Column{ Text { text: '<b>Name:</b> ' + name } Text { text: '<b>Number:</b> ' + number } } } }
and one of the
ListView
ListView { anchors.fill: parent model: modelInstance delegate: delegateInstance highlight: Rectangle {color: "lightsteelblue"; radius: 5} focus: true }
Can you post a screenshot with the above changes ?
wrote on 29 Jun 2015, 09:01 last edited by@p3c0 Well, at first it did not show any list at all and after few seconds the ListView background color rectangle appeared (for some reason it was even animated transition). I have tried to launch it several times (out of sheer desperation) and for the third time (what the hell?!) it showed the list and from that time on, it show the list. My QT installation seems to be having some troubles as I had run qmake and rebuilt the solution before as I always do but it didn't help. What did help was to launch it 3 times in a row... ?!
Anyway the list is still top left and not centered with the grid cell.
https://onedrive.live.com/redir?resid=23FE630A02A6BB8!27371&authkey=!AODgc4UQ2oRe2Ko&v=3&ithint=photo%2Cpng -
@p3c0 Well, at first it did not show any list at all and after few seconds the ListView background color rectangle appeared (for some reason it was even animated transition). I have tried to launch it several times (out of sheer desperation) and for the third time (what the hell?!) it showed the list and from that time on, it show the list. My QT installation seems to be having some troubles as I had run qmake and rebuilt the solution before as I always do but it didn't help. What did help was to launch it 3 times in a row... ?!
Anyway the list is still top left and not centered with the grid cell.
https://onedrive.live.com/redir?resid=23FE630A02A6BB8!27371&authkey=!AODgc4UQ2oRe2Ko&v=3&ithint=photo%2Cpng@Aros Now you just have to center the
Text
items. Just addcenterIn
toColumn
Column{ anchors.centerIn: parent Text { text: '<b>Name:</b> ' + name } Text { text: '<b>Number:</b> ' + number } }
-
@Aros Now you just have to center the
Text
items. Just addcenterIn
toColumn
Column{ anchors.centerIn: parent Text { text: '<b>Name:</b> ' + name } Text { text: '<b>Number:</b> ' + number } }
-
@p3c0 Thank's a lot, that what I wanted. And just one last question: What if I were to center it vertically as well?
@Aros vertically meaning ?
-
wrote on 29 Jun 2015, 14:03 last edited by
@p3c0 Well so far it renderes the lists within the grid cell horizontally centered (within the cell), but they are placed directly under the top of the cell which doesn't look good. I need to move the whole list little bit down (not necessarily center it). The thing is that since there is the "anchors.fill: parent" I cannot write something like "y: 50" to shift it down.
-
@p3c0 Well so far it renderes the lists within the grid cell horizontally centered (within the cell), but they are placed directly under the top of the cell which doesn't look good. I need to move the whole list little bit down (not necessarily center it). The thing is that since there is the "anchors.fill: parent" I cannot write something like "y: 50" to shift it down.
@Aros Well add a margin to
ListView
anchors.topMargin: 50
-
@Aros Glad that it worked. Please mark the post as solved if done.
-
@p3c0 Sorry but I don't know how to do that. There's no button for that. I tried to google it out, but I only found forum posts that complain they do not know how to do that...
@Aros Edit the post title and prepend [Solved].
14/14