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. determining remaining space in a View?
Forum Updated to NodeBB v4.3 + New Features

determining remaining space in a View?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 427 Views 2 Watching
  • 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    This is a stub of my main.qml:

    ApplicationWindow {
        visible: true
        width: Qt.platform.os === "android" ? Screen.width : 800
        height: Qt.platform.os === "android" ? Screen.desktopAvailableHeight : 480
        Column {
            spacing: 0
            MainTabBar { id: navBar }
            ServiceMode { id: serviceModePane }
            RadialFilledRect { id: iqBar }
            StatusBar { id: statusBar }
            Maincontent { id: mainContent } // StackLayout that points to Pane below.
        }
    }
    

    And the file opened by the StackLayout in Maincontent:

    Pane {
        id: equipmentScreenPane
        Layout.fillHeight: true
        Layout.fillWidth: true
        padding: 0
        ColumnLayout {
            anchors.fill: parent
            ListView { id: spaceRow}
            GridView {
                Layout.preferredHeight: mainWindow.height
                                        - navBar.height
                                        - serviceModePane.height
                                        - iqBar.height
                                        - statusBar.height
                                        - spaceRow.height
    

    Is there an easier way to derive the remaining height? I tried Layout.fillHeight: true, but that didn't work right, and I tried using equipmentScreenPane.availableHeight as a starting point, but that led to a Polish loop.

    Is there a more automatic way of doing this?

    Thanks...

    sierdzioS 1 Reply Last reply
    0
    • mzimmersM mzimmers

      Hi all -

      This is a stub of my main.qml:

      ApplicationWindow {
          visible: true
          width: Qt.platform.os === "android" ? Screen.width : 800
          height: Qt.platform.os === "android" ? Screen.desktopAvailableHeight : 480
          Column {
              spacing: 0
              MainTabBar { id: navBar }
              ServiceMode { id: serviceModePane }
              RadialFilledRect { id: iqBar }
              StatusBar { id: statusBar }
              Maincontent { id: mainContent } // StackLayout that points to Pane below.
          }
      }
      

      And the file opened by the StackLayout in Maincontent:

      Pane {
          id: equipmentScreenPane
          Layout.fillHeight: true
          Layout.fillWidth: true
          padding: 0
          ColumnLayout {
              anchors.fill: parent
              ListView { id: spaceRow}
              GridView {
                  Layout.preferredHeight: mainWindow.height
                                          - navBar.height
                                          - serviceModePane.height
                                          - iqBar.height
                                          - statusBar.height
                                          - spaceRow.height
      

      Is there an easier way to derive the remaining height? I tried Layout.fillHeight: true, but that didn't work right, and I tried using equipmentScreenPane.availableHeight as a starting point, but that led to a Polish loop.

      Is there a more automatic way of doing this?

      Thanks...

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @mzimmers perhaps Layout.fillHeight would work better if you also used layouts in main.qml?

      Also, make sure you provide preferredHeight for your ListView, because only then GridView will know how much space it has left and how much it can expand to.

      (Z(:^

      mzimmersM 1 Reply Last reply
      1
      • sierdzioS sierdzio

        @mzimmers perhaps Layout.fillHeight would work better if you also used layouts in main.qml?

        Also, make sure you provide preferredHeight for your ListView, because only then GridView will know how much space it has left and how much it can expand to.

        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by mzimmers
        #3

        @sierdzio I agree that a ColumnLayout is preferable to a mere Column.

        This problem is a bit trickier than I originally indicated. One of my items has conditional height:

        ServiceMode {
            id: serviceModePane
            visible: systemModel.systemMode === SystemNS.SERVICE_MODE
            Layout.preferredHeight: visible ? 56 : 0
        }
        

        And I have a drawer whose height is based on the height of serviceModePane:

        Drawer {
            id: drawer
            height: mainWindow.height - navBar.height - serviceModePane.height
        

        The calculation seems to use the visible height (56) even when the pane isn't visible. Any idea why this is happening?

        EDIT:

        A workaround for this is:

        Drawer {
            height: serviceModePane.visible ? mainWindow.height - navBar.height - serviceModePane.height
                                            : mainWindow.height - navBar.height
        

        And I don't mind doing this; I just don't understand why this is necessary.

        Thanks...

        1 Reply Last reply
        0
        • mzimmersM mzimmers has marked this topic as solved on
        • mzimmersM mzimmers referenced this topic on

        • Login

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