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. timing of sizing calculations
Forum Updated to NodeBB v4.3 + New Features

timing of sizing calculations

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 305 Views 1 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 -

    I've got some code that looks like this:

    ListModel {
        id: settingsModel
        ListElement { rowName: "LAN Connection"; rowIcon: "qrc:/icons/Display.svg" }
        ListElement { rowName: "WAN Connection"; rowIcon: "qrc:/icons/DateTime.svg" }
        ListElement { rowName: "Server"; rowIcon: "qrc:/icons/Temp.svg" }
        ListElement { rowName: "Site Connection"; rowIcon: "qrc:/icons/DisplaySettings.svg" }
    }
    
    ListView {
        id: networkSettingsListView
        Component.onCompleted: console.log("networkSettingsListView.width", width)
        delegate: DelegateChooser {
            model: settingsModel
            role: "rowName"
            DelegateChoice {
                roleValue: "LAN Connection"
                delegate: networkDelegate
            }
        }
    }
    
    Component {
        id: networkDelegate
        Pane {
            id: networkDelegatePane
            Component.onCompleted: console.log("networkDelegatePane.width", width)
            width: networkSettingsListView.width
            ...
    

    At runtime, I get this:

    debug:qml:expression for onCompleted: networkDelegatePane.width 0.
    debug:qml:expression for onCompleted: networkSettingsListView.width 512.
    

    I need the correct width value in my component, as I use it to size items within the component. Is there some way to get this to happen automatically?

    Thanks...

    1 Reply Last reply
    0
    • GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #4

      The width: networkSettingsListView.width should be enough.
      Provide a minimal reproducible example. The ListView has no width set in the code you pasted.

      mzimmersM 1 Reply Last reply
      1
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by
        #2

        Use declarative bindings and don't rely on Component.onCompleted.

        1 Reply Last reply
        1
        • mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote on last edited by mzimmers
          #3

          hi @GrecKo - the Component.onCompleted is strictly for logging; I'm not trying to do any resizing with it.

          When you say "use declarative bindings," do you mean something more than what I'm doing here?

          Pane {
              id: networkDelegatePane
              Component.onCompleted: console.log("networkDelegatePane.width", width)
              width: networkSettingsListView.width
          

          Thanks...

          1 Reply Last reply
          0
          • GrecKoG Offline
            GrecKoG Offline
            GrecKo
            Qt Champions 2018
            wrote on last edited by
            #4

            The width: networkSettingsListView.width should be enough.
            Provide a minimal reproducible example. The ListView has no width set in the code you pasted.

            mzimmersM 1 Reply Last reply
            1
            • GrecKoG GrecKo

              The width: networkSettingsListView.width should be enough.
              Provide a minimal reproducible example. The ListView has no width set in the code you pasted.

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

              @GrecKo said in timing of sizing calculations:

              The ListView has no width set in the code you pasted.

              Right you are. I added explicit width to the ListView, and it now seems to size properly. I guess the console logs I put in were a bit misleading. Thanks!

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

              • Login

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