Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can I able to use "setMethod" as a slot also?

Can I able to use "setMethod" as a slot also?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 515 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.
  • T Offline
    T Offline
    thippu
    wrote on last edited by
    #1

    Hi,

    1. I have member int sampling_rate; and setter method void setSampling_rate(int); and getter method int getSampling_rate(); in ampconfiguration.cpp
    2. I have used also
      Q_PROPERTY(int sampling_rate READ getSampling_rate WRITE setSampling_rate NOTIFY valueChanged)
      3)Now, In the mainwindow.cpp I want send the value from one object to another object of same class, but not working.
    AmpConfiguration Amp1,Amp2;
    
    connect(Amp1.sampling_rate,SIGNAL(valueChanged(int)),Amp2.sampling_rate,SLOT(setSampling_rate(int)));
    

    errors:
    3 errors link

    J.HilkJ 1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      connect(Amp1,&AmpConfiguration::valueChanged,Amp2,&AmpConfiguration::setSampling_rate);

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      5
      • T thippu

        Hi,

        1. I have member int sampling_rate; and setter method void setSampling_rate(int); and getter method int getSampling_rate(); in ampconfiguration.cpp
        2. I have used also
          Q_PROPERTY(int sampling_rate READ getSampling_rate WRITE setSampling_rate NOTIFY valueChanged)
          3)Now, In the mainwindow.cpp I want send the value from one object to another object of same class, but not working.
        AmpConfiguration Amp1,Amp2;
        
        connect(Amp1.sampling_rate,SIGNAL(valueChanged(int)),Amp2.sampling_rate,SLOT(setSampling_rate(int)));
        

        errors:
        3 errors link

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

        hi @thippu

        I think you have two options.

        1. move the void setSampling_rate() from the puclic: section to public slots:
          the Q_Property macro should not care either way, I may be wrong however

        2. use the new QT5 Syntax that way your receiving function does not have to be a defined as slot


        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
        4
        • T Offline
          T Offline
          thippu
          wrote on last edited by
          #4

          @VRonin @J-Hilk 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