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. What determines the difference?

What determines the difference?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 296 Views
  • 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.
  • hslee_6560H Offline
    hslee_6560H Offline
    hslee_6560
    wrote on last edited by hslee_6560
    #1

    Hi, I am a beginner, It could be silly question, but I didn't find the reason.
    Please, any comments, Thank you.

    I was following an qml-example.

    The example code and my code are exactly the same, but I found a difference in output.

    When resizing the window with a mouse, in the example the logs are logged via the onWidthChanged handler, but not in my code.

    I checked code again even QtQuick version and debugger version.

    Can you guess what makes this difference ?

    ------ code

    Rectangle {
        id: root
        width: 320
        height: 440
        onWidthChanged: console.log('width changed : ' + width)
        onHeightChanged: console.log('height changed : ' + height)
    }
    
    aha_1980A 1 Reply Last reply
    0
    • hslee_6560H hslee_6560

      Hi, I am a beginner, It could be silly question, but I didn't find the reason.
      Please, any comments, Thank you.

      I was following an qml-example.

      The example code and my code are exactly the same, but I found a difference in output.

      When resizing the window with a mouse, in the example the logs are logged via the onWidthChanged handler, but not in my code.

      I checked code again even QtQuick version and debugger version.

      Can you guess what makes this difference ?

      ------ code

      Rectangle {
          id: root
          width: 320
          height: 440
          onWidthChanged: console.log('width changed : ' + width)
          onHeightChanged: console.log('height changed : ' + height)
      }
      
      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @hslee_6560,

      can you show your code?

      Qt has to stay free or it will die.

      1 Reply Last reply
      0
      • IntruderExcluderI Offline
        IntruderExcluderI Offline
        IntruderExcluder
        wrote on last edited by
        #3

        There is not enugh code. But if your Rectangle doesn't attached to a root window via anchors or you have no any bindings to width/height property you will never get any changes when resizing window by mouse.
        Working fine example:

        Window {
            visible: true
            width: 640
            height: 480
            title: qsTr("Hello World")
        
            Rectangle {
                anchors.centerIn: parent
                width:  parent.width * 0.5
                height: parent.height * 0.5
                onWidthChanged: console.log('width changed : ' + width)
                onHeightChanged: console.log('height changed : ' + height)
                color: "teal"
            }
        }
        
        1 Reply Last reply
        3

        • Login

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