Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOLVED] QML: GridView and spacing between children

[SOLVED] QML: GridView and spacing between children

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 3 Posters 23.6k 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.
  • S Offline
    S Offline
    spode
    wrote on last edited by
    #1

    How to set the spacing between the children of gridview in QML?
    @
    // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
    import QtQuick 1.0

    Rectangle
    {
    signal selected(string sezione) //[PATHiMMAGINI]/Deutschland <-> [PATHiMMAGINI]/Italia

    property int lunghezza: 600
    property int altezza: 400
    
    color: "transparent"
    width: lunghezza - 60
    height: altezza - 30
    GridView
    {
        anchors.fill: parent
        highlight: Rectangle { radius: 5; color: "lightsteelblue" }
        model: modelSezioni
        delegate:
            Flipable {
            property bool flipped: false
    
            id: flipableCard
            width: 105
            height: 70
    
            front: Image { source: bandiera1; id: img1; anchors.centerIn: parent }
            back: Image { id: img2; source: bandiera2; anchors.centerIn: parent }
    
            transform: Rotation {
                id: rotation
                angle: 0
                origin.x: flipableCard.width / 2
                origin.y: flipableCard.height / 2
                axis.x: 1 //questo flipable girerĂ  sull'asse x, in verticale
                axis.z: 0
                axis.y: 0
            }
    
            Timer
            {
                interval: intervalloDiRotazione
                repeat: true
                running: true
                onTriggered: { flipableCard.flipped = !flipableCard.flipped; }
            }
    
            states: State {
                name: "back"
                when: flipableCard.flipped
                PropertyChanges { target: rotation; angle: 180 }
            }
    
            transitions: Transition {
                NumberAnimation { target: rotation; property: "angle"; duration: 1500 }
            }
    
            MouseArea {
                anchors.fill: parent
                onClicked: { selected(bandiera1 + " <-> " + bandiera2); }
            }
        }
    }
    

    }
    @

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jys0224
      wrote on last edited by
      #2

      afaik, gridview dose not have 'spacing' properties.
      but i think you can effectively set a spacing by using cellWidth, cellHeight property, delegate's width/height
      like,,,

      @
      GridView {
      ...
      cellHeight: 110
      cellWidth:110

      delegate : Item {
      x:10
      y: 10
      width: 100
      height: 100
      ....
      }
      }
      @

      or how about using delegates as nested Item
      like..

      @
      GridView {
      ......
      delegate : Item {
      width:110
      height: 110

         Item {
              width: 100
              height: 100
              anchors.centerIn:parent
              ...
          }
      

      }
      @

      A 1 Reply Last reply
      0
      • S Offline
        S Offline
        spode
        wrote on last edited by
        #3

        Thank you
        this is enough for that:
        @
        GridView
        {
        cellWidth:100
        cellHeight:100
        ...
        }
        @

        1 Reply Last reply
        0
        • J jys0224

          afaik, gridview dose not have 'spacing' properties.
          but i think you can effectively set a spacing by using cellWidth, cellHeight property, delegate's width/height
          like,,,

          @
          GridView {
          ...
          cellHeight: 110
          cellWidth:110

          delegate : Item {
          x:10
          y: 10
          width: 100
          height: 100
          ....
          }
          }
          @

          or how about using delegates as nested Item
          like..

          @
          GridView {
          ......
          delegate : Item {
          width:110
          height: 110

             Item {
                  width: 100
                  height: 100
                  anchors.centerIn:parent
                  ...
              }
          

          }
          @

          A Offline
          A Offline
          aperception
          wrote on last edited by
          #4

          Using cell width & cell height is not the same thing as a vertical / horizontal spacing. For example if you set cell width to the desired width plus the desired horizontal spacing, then you end up with an extra unwanted spacing on the end cells. It kind of boggles my mind how such basic functionality is not included, and nobody complains.

          1 Reply Last reply
          0

          • Login

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