Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to center a gridview in the parent element?

How to center a gridview in the parent element?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
gridview
2 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex M
    wrote on last edited by
    #1

    Hello.
    I have a GridView and a model, but it looks ugly https://yadi.sk/i/lfrJRoCbqDV5k
    Of course I can calculate values of the margins, may be is there a better way?

    import QtQuick 2.3
    import QtQuick.Controls 1.2
    
    ApplicationWindow {
        visible: true
        height: 480
        width: 320
    
        GridView {
            cellHeight: 120
            cellWidth: 120
            anchors.fill: parent
            anchors.centerIn: parent
            model: MenuModel{}
            delegate: delegate
        }
    
    }
    
    1 Reply Last reply
    0
    • L Offline
      L Offline
      Leonardo
      wrote on last edited by
      #2

      Doing calculations is the best way. Please, see:

      https://forum.qt.io/topic/64977/alignment-questions-for-qml-gridview

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved