Center GridView Rows on screen



  • Suppose I have a GridView whose width takes up the whole screen. I want the item rows to be centered on the screen. How do I do it?


  • Moderators

    Hi,

    Can you show what you have tried and what was the effect and how you actually want it to look ?
    Is anchors.centerIn you looking for ?



  • Hi p3cO,

    Normally, anchors.centerIn would do the job but there may be a situation where the GridView is not filled with items all the way to the edge of its container (depending on number of items available or differences in available screen width). In that case centering the GridView does not actually center the items contained therein.
    I was hoping the GridView implementer's would have found a nice solution for that. Turns out, I think I will have to use a little math and determine what the actual combined width of the items will amount to for a single row of the grid and then set the width of the GridView to that before centering.
    If anyone has a more elegant solution I would be glad to hear it.

    thanks

    BD


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.