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. Change layout attached properties

Change layout attached properties

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 1.0k 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.
  • E Offline
    E Offline
    Eligijus
    wrote on last edited by
    #1

    Hello,
    I want to change mBlueRect Layout.maximumHeight property in main.qml how can this be accomplished?

    //main.qml
    import QtQuick 2.6
    import QtQuick.Window 2.2
    
    Window {
        visible: true
        width: 640
        height: 480
    
        Test {
            anchors.fill: parent
            blueRect.Layout.maximumHeight: 100 //This doesn't work
        }
    }
    
    //Test.qml
    import QtQuick 2.6
    import QtQuick.Layouts 1.3
    
    ColumnLayout {
        property alias blueRect: mBlueRect
    
        Rectangle {
            id: redRect
            Layout.fillHeight: true
            Layout.fillWidth: true
            color: "red"
        }
        Rectangle {
            id: mBlueRect
            Layout.fillHeight: true
            Layout.fillWidth: true
            Layout.maximumHeight: 20
            color: "blue"
        }
    }
    
    E 1 Reply Last reply
    0
    • E Eligijus

      Hello,
      I want to change mBlueRect Layout.maximumHeight property in main.qml how can this be accomplished?

      //main.qml
      import QtQuick 2.6
      import QtQuick.Window 2.2
      
      Window {
          visible: true
          width: 640
          height: 480
      
          Test {
              anchors.fill: parent
              blueRect.Layout.maximumHeight: 100 //This doesn't work
          }
      }
      
      //Test.qml
      import QtQuick 2.6
      import QtQuick.Layouts 1.3
      
      ColumnLayout {
          property alias blueRect: mBlueRect
      
          Rectangle {
              id: redRect
              Layout.fillHeight: true
              Layout.fillWidth: true
              color: "red"
          }
          Rectangle {
              id: mBlueRect
              Layout.fillHeight: true
              Layout.fillWidth: true
              Layout.maximumHeight: 20
              color: "blue"
          }
      }
      
      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @Eligijus Try:

      //main.qml
      ...
      Test {
              anchors.fill: parent
              maxH: 100
          }
      ...
      //Test.qml
      ...
      ColumnLayout {
      property int maxH: 20
      ...
      Layout.maximumHeight: maxH
      
      E 1 Reply Last reply
      1
      • E Eeli K

        @Eligijus Try:

        //main.qml
        ...
        Test {
                anchors.fill: parent
                maxH: 100
            }
        ...
        //Test.qml
        ...
        ColumnLayout {
        property int maxH: 20
        ...
        Layout.maximumHeight: maxH
        
        E Offline
        E Offline
        Eligijus
        wrote on last edited by
        #3

        @Eeli-K Thanks. But why can't I write something like this?

        property alias myMax: Layout.maximumHeight
        
        E 1 Reply Last reply
        0
        • E Eligijus

          @Eeli-K Thanks. But why can't I write something like this?

          property alias myMax: Layout.maximumHeight
          
          E Offline
          E Offline
          Eeli K
          wrote on last edited by
          #4

          @Eligijus I think attached properties just behave differently. They are available only for the object they are attached to and can't be aliased, either. We have to live with that.

          Syntactically and semantically this "Layout" or "Layout.maximumHeight" isn't a property of the object which uses it. Therefore you can't refer to it like to object's own properties.

          1 Reply Last reply
          1

          • Login

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