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. Signal handler onAnchorsChanged is throwing error.

Signal handler onAnchorsChanged is throwing error.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 948 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.
  • N Offline
    N Offline
    Nitheesh
    wrote on last edited by
    #1

    When the following code is ran, qml is throwing loading error.

    import QtQuick 2.6
    import QtQuick.Window 2.2
    import QtQuick.Controls 1.0
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("App1")
    
        Item {
            id: panel
            anchors.verticalCenter: parent.verticalCenter
            visible: true
            width: 100
    
            onAnchorsChanged: console.log("anchors changed")
        }
    }
    
    

    i am seeing error message as : qrc:/main.qml:17 Cannot assign to non-existent property "onAnchorsChanged" .
    What is causing the error? i was just curious whether this has any special use case or not.

    Thanks in advance.

    raven-worxR 1 Reply Last reply
    0
    • N Nitheesh

      When the following code is ran, qml is throwing loading error.

      import QtQuick 2.6
      import QtQuick.Window 2.2
      import QtQuick.Controls 1.0
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("App1")
      
          Item {
              id: panel
              anchors.verticalCenter: parent.verticalCenter
              visible: true
              width: 100
      
              onAnchorsChanged: console.log("anchors changed")
          }
      }
      
      

      i am seeing error message as : qrc:/main.qml:17 Cannot assign to non-existent property "onAnchorsChanged" .
      What is causing the error? i was just curious whether this has any special use case or not.

      Thanks in advance.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Nitheesh
      anchors is a grouped property which never changes, thus it has no notify signal and also no corresponding slot.
      Only the properties of the anchors object change.

      So you rather need to do anchors.onCerticalCenterChanged: { ... }

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      N 1 Reply Last reply
      2
      • raven-worxR raven-worx

        @Nitheesh
        anchors is a grouped property which never changes, thus it has no notify signal and also no corresponding slot.
        Only the properties of the anchors object change.

        So you rather need to do anchors.onCerticalCenterChanged: { ... }

        N Offline
        N Offline
        Nitheesh
        wrote on last edited by
        #3

        @raven-worx Thank u. Could you please explain why the anchors doesn't change? Does this mean that other properties for eg: onWidthChanged changes ?

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by VRonin
          #4

          As @raven-worx already told, anchors is grouped property. It just a wrapper to group related properties. What changes here is the property which is inside the grouped property. e.g anchors.top, anchors.bottom etc will change you need to handle property change of these. anchors.onTopChange().. anchors.onBottomChanged()..

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

          1 Reply Last reply
          0
          • dheerendraD Offline
            dheerendraD Offline
            dheerendra
            Qt Champions 2022
            wrote on last edited by
            #5

            @Nitheesh If the issue is resolved, move the issue to SOLVED state.

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

            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