[Solved] GridView wraps to late.



  • Hi there,

    I am new to using QML, so I don't really know if the GridVirew's behavior is normal.
    GridView wraps it's content at some point, but to late, so the last element on each row gets clipped.

    Also the scene produces following message:
    @Cannot create accessible interface for object: QQuickRectangle(0x9d9e820)@

    I don't know why this error message is produced, since everything seems to working right.


    Please enlighten me.

    Last element gets clipped:
    !http://s9.postimg.org/wdcswspmn/2013_03_26_22_35_41_Grid_Cuts_Wrapped.png(Grid clipps content)!

    Code to reproduce:
    @import QtQuick 2.0

    Rectangle {
    width: 300
    height: 300
    color: "gray"

    Rectangle {
    anchors.fill: parent
    anchors.margins: 10
    color: "white"

    GridView {
    id: grid
    anchors.fill: parent
    cellWidth: 80; cellHeight: 80
    clip: true
    highlight: Rectangle { color: "darkgray"; radius: 10 }
    focus: true

    model: ListModel {
    ListElement { color: "red"; text: "red" }
    ListElement { color: "blue"; text: "blue" }
    ListElement { color: "yellow"; text: "yellow" }
    ListElement { color: "red"; text: "red" }
    ListElement { color: "blue"; text: "blue" }
    ListElement { color: "yellow"; text: "yellow" }
    }
    delegate: Rectangle {
    width: grid.cellWidth; height: grid.cellHeight
    color: "transparent"
    border.color: "black"
    radius: 10

    Column {
     anchors.fill: parent
     anchors.topMargin: 10
     Rectangle {
      anchors.horizontalCenter: parent.horizontalCenter
      width: 60; height: 50; color: model.color
     }
     Text {
      anchors.horizontalCenter: parent.horizontalCenter
      text: model.text;
     }
    }
    

    }
    }
    }
    }
    @



  • The bug you found was probably already reported here:
    https://bugreports.qt-project.org/browse/QTBUG-29436

    Since this is a bug in the component itself and behavior might change in the future, the safest way to work around it would be to ensure that the with of your grid view is an exact multiple of cellWidth. You can do this by not filling to parent and assigning the width yourself.

    I believe you can ignore the warning safely and there has already been issued a fix for it here: https://bugreports.qt-project.org/browse/QTBUG-29720



  • Thanks a lot.
    That answers my question.


Log in to reply
 

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