Qt Forum

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

    Solved displaying multiple columns using grid view

    QML and Qt Quick
    gridview
    2
    3
    900
    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.
    • C
      clarity last edited by

      Hey,

      I'm having some trouble with the grid view component displaying multiple columns. What I'm trying to do is display 2 columns with each column taking up half of the display. This is sort of a newbie question, but I'm not able to find examples of this or documentation that describes what I'm trying to do.

      Here's the code:
      import QtQuick 2.5
      import QtQuick.Controls 1.4
      import QtQuick.Layouts 1.2
      import QtQuick.Dialogs 1.2

      ApplicationWindow {
      id: mainWindow
      visible: true
      width: 640
      height: 480
      title: qsTr("Block Explorer")

          Component {
              id: gridComp
              Row {
                  Column {
                      Text {
                          text: blocknum
      
                          MouseArea {
                              anchors.fill: parent
                              onClicked: {
                                  list.currentIndex = index;
                                  var component = Qt.createComponent("qrc:/detail.qml")
                                  var window    = component.createObject(mainWindow)
                                  window.show()
                                  mainWindow.hide()
                              }
                          }
                      }
                  }
                  Column {
                      Text {
                          text: time
                      }
                  }
              }
          }
      
          GridView {
              id: list
              model: mc
              anchors.fill: parent
              cellWidth: parent.width;
              cellHeight: 15
              delegate: gridComp
              highlight: Rectangle {
                   color: 'grey'
              }
              focus: true
              Keys.onPressed: {
                  var pageDown = currentIndex+10;
                  var pageUp = currentIndex-10;
                  if (event.key === Qt.Key_PageDown && event.modifiers === Qt.NoModifier) {
                      currentIndex = pageDown >= count ? count-1 : pageDown;
                      event.accepted = true;
                  }
                  if (event.key === Qt.Key_PageUp && event.modifiers === Qt.NoModifier) {
                      currentIndex = pageUp < 0 ? 0 : pageUp;
                      event.accepted = true;
                  }
              }
          }
      

      }

      Thanks,
      Ryan

      C 1 Reply Last reply Reply Quote 0
      • C
        clarity @clarity last edited by

        @clarity The Gridview is not a table. It's a list that wraps around

        1 Reply Last reply Reply Quote 0
        • T
          Tannz0rz last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • First post
            Last post