Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. displaying multiple columns using grid view
Forum Updated to NodeBB v4.3 + New Features

displaying multiple columns using grid view

Scheduled Pinned Locked Moved Solved QML and Qt Quick
gridview
3 Posts 2 Posters 1.1k 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.
  • C Offline
    C Offline
    clarity
    wrote on 23 Feb 2016, 16:35 last edited by
    #1

    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 24 Feb 2016, 17:32
    0
    • C clarity
      23 Feb 2016, 16:35

      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 Offline
      C Offline
      clarity
      wrote on 24 Feb 2016, 17:32 last edited by
      #2

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

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tannz0rz
        wrote on 28 Feb 2016, 03:07 last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0

        3/3

        28 Feb 2016, 03:07

        • Login

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