2017-10-17 10 views
2

Il fonctionne bien pour les Flickable (à savoir Flickable avec Grid et même Rectangle s (voir le code ci-dessous) à l'intérieur).GridView: leftMargin et propriétés rightmargin doesn fonctionnent pas

Voici un exemple pour GridView:

import QtQuick 2.7 
import QtQuick.Controls 1.4 

ApplicationWindow { 
    id: rootWindow 

    visible: true 
    width: 300 
    height: 300 

    Rectangle { 
     anchors.fill: parent 
     color: "yellow" 

     GridView { 
      id: gridView 
      anchors.fill: parent 

      cellWidth: 50 
      cellHeight: 50 
      model: 54 

      bottomMargin: 10 
      topMargin: 10 
      leftMargin: 10 // this doesn't work 
      rightMargin: 10 // this doesn't work 

      delegate: Rectangle { 
       width: gridView.cellWidth - 1 
       height: gridView.cellHeight - 1 
       color: "green" 
      } 
     } 
    } 
} 

Suis-je manque quelque chose ou est-ce simplement un bug?

+0

On dirait que smth bizarre se passe, en fait - je déposer cela à https://bugreports.qt.io et voir ce qu'ils disent. GridXXX a beaucoup de problèmes, je pense, donc pas de surprise. – mlvljr

Répondre

1

peut-être thats ce que vous cherchez:

... 
    GridView { 
     id: gridView 
     anchors { 
      fill: parent 
      margins: 10 
     } 
     clip: true 

     cellWidth: 50 
     cellHeight: 50 
     model: 54 

     delegate: Rectangle { 
      width: gridView.cellWidth - 1 
      height: gridView.cellHeight - 1 
      color: "green" 
     } 
    } 
    ...