Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Solved] GridView wraps to late.

    QML and Qt Quick
    2
    3
    1553
    Loading More Posts
    • 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.
    • K
      Kysymys last edited by

      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;
       }
      }
      

      }
      }
      }
      }
      @

      \o/ \o/ Kudos ...

      Paholaisen Kysymys

      1 Reply Last reply Reply Quote 0
      • J
        Jens last edited by

        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

        1 Reply Last reply Reply Quote 0
        • K
          Kysymys last edited by

          Thanks a lot.
          That answers my question.

          \o/ \o/ Kudos ...

          Paholaisen Kysymys

          1 Reply Last reply Reply Quote 0
          • First post
            Last post