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. Dialog gets not resized with loader
Forum Updated to NodeBB v4.3 + New Features

Dialog gets not resized with loader

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 2 Posters 832 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.
  • RusticusR Offline
    RusticusR Offline
    Rusticus
    wrote on last edited by
    #1

    Hello,

    I have a dialog,where I load depending on the input of a combo box different QML files with different size, but always some layout.

    The problem is, whenever I select the item in the combo box, the qml file will be loaded but only the first line will be showed, the dialog does not resize properly, when I manually resize it, the content of the qml file is displayed properly.

    How can I tell the Layout to resize or redraw? I have not found a LayChanged signal in the documentation or something similar

    Dialog{
       
        
        ListModel{
            id: comboBoxModel
            ListElement{
                name: "First"
                path: "first.qml"
            }
            ListElement{
                name: "Second"
                path: "second.qml"
            }
        }
    
        ColumnLayout{
            anchors.fill: parent
            GridLayout{
                Layout.fillWidth: true
                columns: 2
                Label{
                    text: "Selection"
                }
                ComboBox{
                    model: comboBoxModel
                    textRole: "name"
                    valueRole: "path"
                    onCurrentIndexChanged: {
                        if (currentIndex > 0)
                        {
                            console.log( currentText, currentValue )
                            loader.setSource( currentValue, {} )
                        }
                        
                    }
                }
            }
            Loader{
                id: loader
                Layout.fillWidth: true
                asynchronous: true
                visible: status == Loader.Ready
                onStatusChanged: {
                    if (status == Loader.Ready){
                        loader.item.visible = true
                    }
                }
            }
        }
    
    }
    
    
    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      I suspect width & height of the loader are the issue. Try to set some size or bind the values to loaded item.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      RusticusR 1 Reply Last reply
      0
      • dheerendraD dheerendra

        I suspect width & height of the loader are the issue. Try to set some size or bind the values to loaded item.

        RusticusR Offline
        RusticusR Offline
        Rusticus
        wrote on last edited by Rusticus
        #3

        @dheerendra
        How to set the height of the loader properly accordingly to it's item?

        Normally the Dialog should resize, right?

        dheerendraD 1 Reply Last reply
        0
        • RusticusR Rusticus

          @dheerendra
          How to set the height of the loader properly accordingly to it's item?

          Normally the Dialog should resize, right?

          dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          @Rusticus

          Try some thing like this for loader

                      ```
          

          height: loader.item != null ? loader.item.height : 0
          width: loader.item != null ? loader.item.width : 0
          Layout.fillWidth: true

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          RusticusR 2 Replies Last reply
          0
          • dheerendraD dheerendra

            @Rusticus

            Try some thing like this for loader

                        ```
            

            height: loader.item != null ? loader.item.height : 0
            width: loader.item != null ? loader.item.width : 0
            Layout.fillWidth: true

            RusticusR Offline
            RusticusR Offline
            Rusticus
            wrote on last edited by
            #5

            @dheerendra

            When I try to print the values I get 0 for both

                    Loader{
                        id: loader
                        Layout.fillWidth: true
                        asynchronous: true
                        visible: status == Loader.Ready
                        onStatusChanged: {
                            if (status == Loader.Ready){
                                loader.item.visible = true
                                console.log( loader.item.height )
                                console.log( loader.item.width )
                            }
                        }
                    }
            
            qml: 0
            qml: 0
            

            When i change the height to something:

                    Loader{
                        id: loader
                        Layout.fillWidth: true
                        asynchronous: true
                        visible: status == Loader.Ready
                        height: loader.item != null ? loader.item.height : 100
                        onStatusChanged: {
                            if (status == Loader.Ready){
                                loader.item.visible = true
                                //console.log( loader.item.height )
                                //console.log( loader.item.width )
                            }
                        }
                        onHeightChanged: console.log( "Loader", height )
                    }
            

            I get the following:

            qml: Loader 100
            
            1 Reply Last reply
            0
            • dheerendraD dheerendra

              @Rusticus

              Try some thing like this for loader

                          ```
              

              height: loader.item != null ? loader.item.height : 0
              width: loader.item != null ? loader.item.width : 0
              Layout.fillWidth: true

              RusticusR Offline
              RusticusR Offline
              Rusticus
              wrote on last edited by
              #6

              @dheerendra
              The problem was the loaded QML, I was using a "anchors.fill: parent"

              Now I get always get 101, but don't know why, is this a default?

              Loaded QML:

              import QtQuick
              import QtQuick.Controls
              import QtQuick.Controls.Material
              import QtQuick.Layouts
              
              import Qt.labs.settings
              
              Item{
                  id: csvRecordImport
                  implicitHeight: gl.height
                  Settings {
                      id: settings
                  }
                  Component.onCompleted: {
                      delimiter.currentIndex = settings.value("ui/importRecordDialog/csv/delimiter", 0)
                      csvHeader.checkState = settings.value("ui/importRecordDialog/csv/csvHeader", Qt.Unchecked)
                  }
                  Component.onDestruction: {
                      settings.setValue("ui/importRecordDialog/csv/delimiter", delimiter.currentIndex)
                      settings.setValue("ui/importRecordDialog/csv/csvHeader", csvHeader.checkState)
                  }
                  signal updated()
              
                  function getParameters()
                  {
                      var parameter = {}
                      parameter["delimiter"] = delimiter.currentValue
                      parameter["header"] = csvHeader.checked
                      var json_str = JSON.stringify(parameter)
                      return json_str
                  }
              
                  GridLayout{
                      id: gl
                      columns: 2
                      Label{
                          text: qsTr("Delimiter:")
                      }
                      ComboBox{
                          id: delimiter
                          Layout.fillWidth: true
                          textRole: "text"
                          valueRole: "value"
                          onCurrentValueChanged: csvRecordImport.updated()
                          model: ListModel{
                              ListElement{ text: qsTr("Comma (Default)"); value: "," }
                              ListElement{ text: qsTr("Semicolon"); value: ";" }
                              ListElement{ text: qsTr("Tab"); value: "\t" }
                          }
                      }
                      CheckBox{
                          id: csvHeader
                          text: qsTr("CSV Header")
                          onCheckStateChanged: csvRecordImport.updated()
                      }
                  }
              }
              
                      Loader{
                          id: loader
                          Layout.fillWidth: true
                          asynchronous: true
                          visible: status == Loader.Ready
                          //height: loader.item != null ? loader.item.height : 100
                          onStatusChanged: {
                              if (status == Loader.Ready){
                                  loader.item.visible = true
                                  //console.log( loader.item.height )
                                  //console.log( loader.item.width )
                              }
                          }
                          onHeightChanged: console.log( "Loader", height )
                      }
                      Connections {
                          target: loader.item
                          function onUpdated() { openFile( filePath.text ) }
                          function onHeightChanged() { console.log( "Item", height ) }
                      }
              

              When I use the implicitHeight of the I get:

              qml: Loader 101
              

              But I see all of the item including a lot of free space

              With height I get:

              qml: Loader 101
              qml: Item 429
              qml: Loader 0
              
              1 Reply Last reply
              0
              • RusticusR Offline
                RusticusR Offline
                Rusticus
                wrote on last edited by Rusticus
                #7

                Still I havent found a solution

                What I have found out so far, the Item I load gets the height of 101 but why?

                1 Reply Last reply
                0
                • RusticusR Rusticus 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