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. Deriving "leftover" space value
Forum Updated to NodeBB v4.3 + New Features

Deriving "leftover" space value

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 4 Posters 413 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 -

    Consider this code snippet:

    ColumnLayout {
        id: newZone
    
        // other stuff
        
        ListView {
            id: viewArea
            Layout.preferredHeight: // what do I put here?
            Layout.preferredWidth: newZone.width
            clip: true
            model: 100
            delegate: Text { text: model.index; font.pixelSize: 10 }
        }
    }
    

    Is there a way to automatically derive the available space for my ListView's height, or do I need to do the arithmetic of:

    leftover = newZone.height - otherStuff.height
    

    Thanks...

    JoeCFDJ 1 Reply Last reply
    0
    • mzimmersM mzimmers

      @JoeCFD I don't want to set the ListView height to its content height; that causes the problem I'm trying to solve. I want to set the ListView height to whatever is available.

      GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by GrecKo
      #4

      Layout.fillHeight: true uses all the remaining height.

      mzimmersM 1 Reply Last reply
      2
      • mzimmersM mzimmers

        Hi all -

        Consider this code snippet:

        ColumnLayout {
            id: newZone
        
            // other stuff
            
            ListView {
                id: viewArea
                Layout.preferredHeight: // what do I put here?
                Layout.preferredWidth: newZone.width
                clip: true
                model: 100
                delegate: Text { text: model.index; font.pixelSize: 10 }
            }
        }
        

        Is there a way to automatically derive the available space for my ListView's height, or do I need to do the arithmetic of:

        leftover = newZone.height - otherStuff.height
        

        Thanks...

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #2

        @mzimmers is Layout.preferredHeight equal to 100 * 10(text numbers * font size)?
        But normally there is some space among the rows of ListView.
        It may not be a good idea to do
        delegate: Text { }
        I use
        delegate: Rectangle { }

        mzimmersM 1 Reply Last reply
        0
        • JoeCFDJ JoeCFD

          @mzimmers is Layout.preferredHeight equal to 100 * 10(text numbers * font size)?
          But normally there is some space among the rows of ListView.
          It may not be a good idea to do
          delegate: Text { }
          I use
          delegate: Rectangle { }

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

          @JoeCFD I don't want to set the ListView height to its content height; that causes the problem I'm trying to solve. I want to set the ListView height to whatever is available.

          GrecKoG 1 Reply Last reply
          0
          • mzimmersM mzimmers

            @JoeCFD I don't want to set the ListView height to its content height; that causes the problem I'm trying to solve. I want to set the ListView height to whatever is available.

            GrecKoG Offline
            GrecKoG Offline
            GrecKo
            Qt Champions 2018
            wrote on last edited by GrecKo
            #4

            Layout.fillHeight: true uses all the remaining height.

            mzimmersM 1 Reply Last reply
            2
            • GrecKoG GrecKo

              Layout.fillHeight: true uses all the remaining height.

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

              @GrecKo I knew that. Seriously, I did.

              My app was misbehaving due to some conflicting settings, but once I emptied the trash, it worked just as you said.

              Thanks...

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

                @GrecKo I knew that. Seriously, I did.

                My app was misbehaving due to some conflicting settings, but once I emptied the trash, it worked just as you said.

                Thanks...

                fcarneyF Offline
                fcarneyF Offline
                fcarney
                wrote on last edited by
                #6

                @mzimmers said in Deriving "leftover" space value:

                but once I emptied the trash

                https://www.youtube.com/watch?v=Wf7seK3n9rE sorry, not sorry

                C++ is a perfectly valid school of magic.

                1 Reply Last reply
                0

                • Login

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