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. How to pass the parameters between the SIGNAL and SLOTS
Qt 6.11 is out! See what's new in the release blog

How to pass the parameters between the SIGNAL and SLOTS

Scheduled Pinned Locked Moved Solved General and Desktop
45 Posts 3 Posters 22.7k 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.
  • A Alex42

    for more information , i created the principle interface (MainWindow), and in this interface i have two QPushbutton ,the first button open the firste interface (Mesure) , and the second Button open the seconde interface

    • i don't get any messages about the connect failing
      -( i can to change the data between the firste interface (Mesure) and the seconde interface (Mesureone ), but with the QLineEdit i can't to transmite data between this interfaces
    • i used the debugger , and the slot is called and the connect executed . But i can't to interact between this interfaces with the QLineEdit (incredible)
    mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #8

    @Alex42

    Hi
    Your connect seems to be called many times.
    Normally you should only call it once as it will send multiple times if you connect multiple times and
    that is normally not what you want.

    Anyway,

    Are you saying that

    void Mesure :: calculate_3 ()
    {
    
        S++;
    
        if (S>0)
        {
        emit newtextChanged_1(QString::number (ui->lcdNumber_1->value()));  /// works
        but  
        emit newtextChanged_1(mence->text()); // wont work ?
    
    
    1 Reply Last reply
    0
    • A Offline
      A Offline
      Alex42
      wrote on last edited by
      #9

      @mrjj said in How to pass the parameters between the SIGNAL and SLOTS:

      Your connect seems to be called many times.

      there is no probleme if you call it many time or you call it once , i tried many situation ( call it once , and call it many time ) but that not work

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Alex42
        wrote on last edited by
        #10

        @mrjj said in How to pass the parameters between the SIGNAL and SLOTS:

        emit newtextChanged_1(mence->text()); // wont work ?

        emit newtextChanged_1(mence->text()); // wont work ? exactly what i whant to do buthe d'ont work

        mrjjM 1 Reply Last reply
        0
        • A Alex42

          @mrjj said in How to pass the parameters between the SIGNAL and SLOTS:

          emit newtextChanged_1(mence->text()); // wont work ?

          emit newtextChanged_1(mence->text()); // wont work ? exactly what i whant to do buthe d'ont work

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #11

          @Alex42

          Hi
          does
          QString test("hello");
          emit newtextChanged_1(test);

          works ?

          Both should work if the
          QString::number (ui->lcdNumber_1->value()) works.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Alex42
            wrote on last edited by
            #12

            @mrjj , QString test("hello");
            emit newtextChanged_1(test);

            works ?

            yes it works very well

            mrjjM 1 Reply Last reply
            0
            • A Offline
              A Offline
              Alex42
              wrote on last edited by
              #13

              are you undestad that may QLineEdite change every 1000ms ?

              1 Reply Last reply
              1
              • A Alex42

                @mrjj , QString test("hello");
                emit newtextChanged_1(test);

                works ?

                yes it works very well

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #14

                @Alex42

                Ok that is a bit o.O

                so try

                QString text = mence->text();
                qDebug() << "sending:" << text;
                emit ewtextChanged_1(text);

                and see if the mence is the one you think it is as that is my only guess then as
                the signal clearly works :)

                Yes, I understand you change the text of the lineEdit every sec,but that should not matter
                as we just get what ever was set last when we ask.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Alex42
                  wrote on last edited by
                  #15

                  yes exactly what i want , befor i tried this and works very well ,
                  but the probleme is in the second interface i can't receve this data ![alt text](d1227136-64f2-4151-9673-f2de8d04d62e-Capture.PNG image url)
                  ( in the seconde interface i receve only 0( the fiste values) , i can't receive the values when is chenged

                  mrjjM 1 Reply Last reply
                  0
                  • A Alex42

                    yes exactly what i want , befor i tried this and works very well ,
                    but the probleme is in the second interface i can't receve this data ![alt text](d1227136-64f2-4151-9673-f2de8d04d62e-Capture.PNG image url)
                    ( in the seconde interface i receve only 0( the fiste values) , i can't receive the values when is chenged

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #16

                    @Alex42

                    So in interface 2, you only see the "0" and never "12222" etc ?

                    But you could send "hello" and other string ?
                    That I cant explain. seems impossible.

                    Just so I understand.

                    You have a main window and 2 buttons. Each button opens a new Form/window and
                    form1 has a timer or something that makes a lineEdit count/set some value.
                    This value you try to emit to form2 when calculate_3 is called ?

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Alex42
                      wrote on last edited by
                      #17

                      @mrjj said in How to pass the parameters between the SIGNAL and SLOTS:

                      So in interface 2, you only see the "0" and never "12222" etc ?

                      So in interface 2, you only see the "0" and never "12222" etc ? yes exactly
                      But you could send "hello" and other string ? yes i can send hello
                      You have a main window and 2 buttons. Each button opens a new Form/window and
                      form1 has a timer or something that makes a lineEdit count/set some value.
                      This value you try to emit to form2 when calculate_3 is called ? exactly what i want to do

                      mrjjM 1 Reply Last reply
                      0
                      • A Alex42

                        @mrjj said in How to pass the parameters between the SIGNAL and SLOTS:

                        So in interface 2, you only see the "0" and never "12222" etc ?

                        So in interface 2, you only see the "0" and never "12222" etc ? yes exactly
                        But you could send "hello" and other string ? yes i can send hello
                        You have a main window and 2 buttons. Each button opens a new Form/window and
                        form1 has a timer or something that makes a lineEdit count/set some value.
                        This value you try to emit to form2 when calculate_3 is called ? exactly what i want to do

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #18

                        @Alex42
                        Ok. how is the LineEdit updated ?
                        a Qtimer ?

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          Alex42
                          wrote on last edited by
                          #19

                          yes a Qtimer

                          mrjjM 1 Reply Last reply
                          0
                          • A Alex42

                            yes a Qtimer

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #20

                            @Alex42

                            Ok. hang on for 20 mins. Ill try myself as it does seem strange :)

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              Alex42
                              wrote on last edited by
                              #21

                              @mrjj said in How to pass the parameters between the SIGNAL and SLOTS:

                              Ok. hang on for 20 mins. Ill try myself as it does seem strange :)

                              ok thank you very match for your helpe

                              1 Reply Last reply
                              0
                              • A Offline
                                A Offline
                                Alex42
                                wrote on last edited by
                                #22

                                i'm sorry, i have a lot of classe , methode and line of code, and there is interaction between them with QTimer , Mathematique fonction ...etc , for this i can't to post all my code

                                mrjjM 1 Reply Last reply
                                0
                                • A Alex42

                                  i'm sorry, i have a lot of classe , methode and line of code, and there is interaction between them with QTimer , Mathematique fonction ...etc , for this i can't to post all my code

                                  mrjjM Offline
                                  mrjjM Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #23

                                  @Alex42
                                  Thats ok.
                                  I will make a fast example and if that just works, you can have it and have a look.
                                  Maybe we can find out what the difference it. :)

                                  1 Reply Last reply
                                  0
                                  • A Offline
                                    A Offline
                                    Alex42
                                    wrote on last edited by
                                    #24

                                    OK , thank you

                                    1 Reply Last reply
                                    0
                                    • mrjjM Offline
                                      mrjjM Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #25

                                      hi
                                      Seems to work fine even with a 100 MS timer so should work for you too.

                                      Can you please try ?

                                      https://www.dropbox.com/s/l8go4t71unosl05/CrossTalk.zip?dl=0

                                      alt text

                                      1 Reply Last reply
                                      2
                                      • A Offline
                                        A Offline
                                        Alex42
                                        wrote on last edited by
                                        #26

                                        ok , can you show me your code please ;

                                        mrjjM 1 Reply Last reply
                                        0
                                        • A Alex42

                                          ok , can you show me your code please ;

                                          mrjjM Offline
                                          mrjjM Offline
                                          mrjj
                                          Lifetime Qt Champion
                                          wrote on last edited by mrjj
                                          #27

                                          @Alex42
                                          The dropbox link is the full project you can just run.
                                          If not allowed to use dropbox is there any other such service you are allowed to use ?
                                          (you don't have to register. just press the download and you should get zip file)

                                          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