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. Is it possible to make a Connections in a QmlTimer component ?

Is it possible to make a Connections in a QmlTimer component ?

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

    Hi,

    I'm trying to connect a signal from an Item to a Timer using Connections.

    My code fails when I try to run it with the following error PathToMyProject/main.qml:21 Cannot assign to non-existent default property

    If I replace the Timer component by an Item component everything works fine.

    Here is my code:

    import QtQuick 2.12
    import QtQuick.Controls 2.5
    import QtQuick.Window 2.2
    import QtQml 2.12
    
    
    ApplicationWindow{
    	id: root
    	width: 500
    	height: 500
    	visible: true
    
    	Item {
    		id: itemId
    		signal mySignal()
    	}
    
    	Timer { // Replacing the Timer component by an Item component does not trigger any error
    		id: timerId
    		property int nbr: 13
    		Connections // This is the line 21
    		{
    			target: itemId
    			onMySignal: timerId.nbr = 42;
    		}
    	}
    
    	Column {
    		Button { text: "emit signal"; onClicked: itemId.mySignal(); }
    		Button { text: "display nbr"; onClicked: console.log(timerId.nbr); }
    	}
    }
    

    It's like it is not possible to assign a Connections to a Timer component.

    Can someone explain me if I'm right and why ?

    Thank's a lot ^^

    ODБOïO 1 Reply Last reply
    0
    • M Moisi

      Hi,

      Thank you for your answer.

      Yes, this is a solution. ^^

      But I'm still curious about the reason why I can not define the Connections inside the Timer.

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #4

      @Moisi the answer is in the error message
      Cannot assign to non-existent default property

      1 Reply Last reply
      0
      • M Moisi

        Hi,

        I'm trying to connect a signal from an Item to a Timer using Connections.

        My code fails when I try to run it with the following error PathToMyProject/main.qml:21 Cannot assign to non-existent default property

        If I replace the Timer component by an Item component everything works fine.

        Here is my code:

        import QtQuick 2.12
        import QtQuick.Controls 2.5
        import QtQuick.Window 2.2
        import QtQml 2.12
        
        
        ApplicationWindow{
        	id: root
        	width: 500
        	height: 500
        	visible: true
        
        	Item {
        		id: itemId
        		signal mySignal()
        	}
        
        	Timer { // Replacing the Timer component by an Item component does not trigger any error
        		id: timerId
        		property int nbr: 13
        		Connections // This is the line 21
        		{
        			target: itemId
        			onMySignal: timerId.nbr = 42;
        		}
        	}
        
        	Column {
        		Button { text: "emit signal"; onClicked: itemId.mySignal(); }
        		Button { text: "display nbr"; onClicked: console.log(timerId.nbr); }
        	}
        }
        

        It's like it is not possible to assign a Connections to a Timer component.

        Can someone explain me if I'm right and why ?

        Thank's a lot ^^

        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by ODБOï
        #2

        hi
        @Moisi said in Is it possible to make a Connections in a QmlTimer component ?:

        Cannot assign to non-existent default property

        Don't define the Connections inside the Timer.

        Timer {
         d: timerId
         property int nbr: 13
        	}
        
        Connections {
         target: itemId
         onMySignal: timerId.nbr = 42;
        	}
        

        In this context you don't even need Connections

        Item {
         id: itemId
         signal mySignal()
         onMySignal : timerId.nbr = 42;
        }
        
        1 Reply Last reply
        0
        • M Offline
          M Offline
          Moisi
          wrote on last edited by
          #3

          Hi,

          Thank you for your answer.

          Yes, this is a solution. ^^

          But I'm still curious about the reason why I can not define the Connections inside the Timer.

          ODБOïO 1 Reply Last reply
          0
          • M Moisi

            Hi,

            Thank you for your answer.

            Yes, this is a solution. ^^

            But I'm still curious about the reason why I can not define the Connections inside the Timer.

            ODБOïO Offline
            ODБOïO Offline
            ODБOï
            wrote on last edited by
            #4

            @Moisi the answer is in the error message
            Cannot assign to non-existent default property

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Moisi
              wrote on last edited by
              #5

              Oh, yes ! You're right ! Thank you ! ^^

              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