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. Recive Signal inside QML Object
Forum Updated to NodeBB v4.3 + New Features

Recive Signal inside QML Object

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

    I am little bit confused how to receive a signal, I have a signal called onvalueChanged, and according to it I will append data inside my plot! any Advice how to handle it?

    ChartView {
        id:chartView1
     onvalueChanged: lineseries1.append(i, value)
    }
    
    J.HilkJ 1 Reply Last reply
    0
    • M MAthias_Va

      I am little bit confused how to receive a signal, I have a signal called onvalueChanged, and according to it I will append data inside my plot! any Advice how to handle it?

      ChartView {
          id:chartView1
       onvalueChanged: lineseries1.append(i, value)
      }
      
      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @MAthias_Va

      that depends on where the signal actually comes from, can you explain a but more?

      • is it a c++ class somewhere
      • a signal declared inside an other QML-file
      • is it part of the ChartView itself?
      • ....

      In any case, in QML you can access usually signals that are bound to properties by the following Syntax;

      on + propertyName + Changed
      in your case, most likely onValueChanged, but this may or may not be sufficient, you'll have to say where the signal comes from


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      M 1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        @MAthias_Va

        that depends on where the signal actually comes from, can you explain a but more?

        • is it a c++ class somewhere
        • a signal declared inside an other QML-file
        • is it part of the ChartView itself?
        • ....

        In any case, in QML you can access usually signals that are bound to properties by the following Syntax;

        on + propertyName + Changed
        in your case, most likely onValueChanged, but this may or may not be sufficient, you'll have to say where the signal comes from

        M Offline
        M Offline
        MAthias_Va
        wrote on last edited by MAthias_Va
        #3

        Thanks @J.Hilk for your clarification, it is from C++, Q_PROPERTY
        like this on; http://doc.qt.io/qt-5/qtqml-cppintegration-exposecppattributes.html

         Q_PROPERTY(QString value READ value WRITE setValue NOTIFY valueChanged)
        
        J.HilkJ 1 Reply Last reply
        0
        • M MAthias_Va

          Thanks @J.Hilk for your clarification, it is from C++, Q_PROPERTY
          like this on; http://doc.qt.io/qt-5/qtqml-cppintegration-exposecppattributes.html

           Q_PROPERTY(QString value READ value WRITE setValue NOTIFY valueChanged)
          
          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @MAthias_Va
          alight,
          that means, the signal you're actually listening to is indeed

          onValueChanged: //do something

          attention to the capital V

          followup question, how do you instantiate the c++ class?

          If it's registered as a qml component, you'll have to add the line inside that body.
          If it's a context property you'll have to use Connect


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

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

            at the moment I can receive the signal inside my QML file, but My problem is, I canto integrate it as I need!!

            for example If I create a timer inside my ChartView I can receive the signal as below example; which is working as expected

            ChartView {
                id:chartView1
            Timer {
                      id:timer
                      interval: 200 ; running: true; repeat: true;
                      onTriggered: onvalueChanged: lineseries1.append(i, value) //here I don't receive error
            
                       }
                    }                     
            

            but I don't want to use this Timer, I need to receive the signal as my beginning example! Any Ideas?

            ChartView {
                id:chartView1
             onvalueChanged: lineseries1.append(i, value) //here I have error: Cannot assign to non-existent property
            }
            
            J.HilkJ 1 Reply Last reply
            0
            • M MAthias_Va

              at the moment I can receive the signal inside my QML file, but My problem is, I canto integrate it as I need!!

              for example If I create a timer inside my ChartView I can receive the signal as below example; which is working as expected

              ChartView {
                  id:chartView1
              Timer {
                        id:timer
                        interval: 200 ; running: true; repeat: true;
                        onTriggered: onvalueChanged: lineseries1.append(i, value) //here I don't receive error
              
                         }
                      }                     
              

              but I don't want to use this Timer, I need to receive the signal as my beginning example! Any Ideas?

              ChartView {
                  id:chartView1
               onvalueChanged: lineseries1.append(i, value) //here I have error: Cannot assign to non-existent property
              }
              
              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @MAthias_Va
              I'm puzzled the timer works at all!!?!?

              again, how to you access the c++ class?

              did you use

              • qmlRegisterType<yourClass>
              • or setContextProperty
              • or something else

              ?


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              M 1 Reply Last reply
              0
              • J.HilkJ J.Hilk

                @MAthias_Va
                I'm puzzled the timer works at all!!?!?

                again, how to you access the c++ class?

                did you use

                • qmlRegisterType<yourClass>
                • or setContextProperty
                • or something else

                ?

                M Offline
                M Offline
                MAthias_Va
                wrote on last edited by
                #7

                @J.Hilk I use: setContextProperty

                J.HilkJ 1 Reply Last reply
                0
                • M MAthias_Va

                  @J.Hilk I use: setContextProperty

                  J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on last edited by
                  #8

                  @MAthias_Va said in Recive Signal inside QML Object:

                  @J.Hilk I use: setContextProperty

                  alight, assuming the following :

                  rootContext()->setContextProperty("myClass", myClassInstance);

                  than you can do the following

                  ChartView {
                      id:chartView1
                  
                      Connections{
                              target: myClass
                  
                              onValueChanged: console.log("c++ value changed to:", value);
                       }
                  }
                  

                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  M 1 Reply Last reply
                  1
                  • J.HilkJ J.Hilk

                    @MAthias_Va said in Recive Signal inside QML Object:

                    @J.Hilk I use: setContextProperty

                    alight, assuming the following :

                    rootContext()->setContextProperty("myClass", myClassInstance);

                    than you can do the following

                    ChartView {
                        id:chartView1
                    
                        Connections{
                                target: myClass
                    
                                onValueChanged: console.log("c++ value changed to:", value);
                         }
                    }
                    
                    M Offline
                    M Offline
                    MAthias_Va
                    wrote on last edited by
                    #9

                    Thanks @J.Hilk so much, this one is working :) :)

                    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