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

How to pass the parameters between the SIGNAL and SLOTS

Scheduled Pinned Locked Moved Solved General and Desktop
45 Posts 3 Posters 16.4k 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 Offline
    A Offline
    Alex42
    wrote on last edited by
    #31

    i will try to emit the signal every time i do a calculation in this fonction

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

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

      i will try to emit the signal every time i do a calculation in this fonction

      i'm trying to emit the signal every time i do a calculation in this fonction but without success

      case 2 :
                if ( Val0 <Val1)
                {
      
                     ui->lineEdit_17->setText(QString::number(Val9));
           mence->setText(QString::number(Val9));
                     emit newtextChanged_1(mence->text());
                        }
                else if ( ((Val0>Val1) && (Val0<Val2)) || (Val0>2))
                {
                     // V1 = Val0* Val10/Val2;
                    V1= Val10 * (Val0 - Val1)/(Val2-Val1) +Val9 *(Val2-Val0)/(Val2-Val1);
      
                        ui->lineEdit_17->setText(QString::number(V1));
                        emit newtextChanged_1(mence->text());
                       mence->setText(QString::number(V1));
                }
      
      1 Reply Last reply
      0
      • A Offline
        A Offline
        Alex42
        wrote on last edited by
        #33

        incredible , when i try this he work very will

        void Mesure  :: calculate_3 ()
        {
            S++;
        
        
             emit newtextChanged_1(QString::number (S));
        }
        

        but withe this signal he want to work

           emit newtextChanged_1(mence ->text());
        
        mrjjM 1 Reply Last reply
        0
        • A Alex42

          incredible , when i try this he work very will

          void Mesure  :: calculate_3 ()
          {
              S++;
          
          
               emit newtextChanged_1(QString::number (S));
          }
          

          but withe this signal he want to work

             emit newtextChanged_1(mence ->text());
          
          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #34

          @Alex42

          Ok.
          I was wondering one thing.
          All your other linedits are in the UI
          but mence
          is not

          Do you have 2 of them for some reason ?
          so there is also the
          ui->mence ?

          Why is mence not in the UI.
          Do you insert it from code to the fom?

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

            @mrjj ,it's a good question, i coded mence (QlineEdit) with a hand , because , ui->lineEdit_17 ->text () he doesn't work, for this i created mence -> text() ,
            but the bothe not want to work

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

              the ui->lineEdit_17->text() ,and mence ->text() , it's the same thing , just one coded with a hand , and auther coder with Qt creator Form (Ui)

              J.HilkJ 1 Reply Last reply
              0
              • A Alex42

                the ui->lineEdit_17->text() ,and mence ->text() , it's the same thing , just one coded with a hand , and auther coder with Qt creator Form (Ui)

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

                @Alex42
                I'm sure, that if you do:

                void Mesure  :: calculate_3 ()
                {
                    S++;
                
                    mence->setText(QString::number (S));
                     emit newtextChanged_1(mence->text());
                }
                

                it will work just as well as

                void Mesure  :: calculate_3 ()
                {
                    S++;
                
                
                     emit newtextChanged_1(QString::number (S));
                }
                

                somewhere you're setting your mence->text to 0

                I good point to start the debugger and step through your code line by line, btw.


                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
                • A Offline
                  A Offline
                  Alex42
                  wrote on last edited by
                  #38

                  @J-Hilk , thank you for your response , yes i don't any probleme with your code ( it works very will )

                  but the probleme it's when i try to transmete the real values ,
                  are you understande that the real valueu it's not number S ?

                  J.HilkJ 1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Alex42
                    wrote on last edited by
                    #39

                    as i mentioned below, my edited QLine (mence ->text(), OR, ui->lineEdite_17->text()) contains scientific calculation results which change every 1000ms

                    1 Reply Last reply
                    0
                    • A Alex42

                      @J-Hilk , thank you for your response , yes i don't any probleme with your code ( it works very will )

                      but the probleme it's when i try to transmete the real values ,
                      are you understande that the real valueu it's not number S ?

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

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

                      are you understande that the real valueu it's not number S ?

                      I do, do you realise, that mence is not the problem here ?

                      on a hinge: try the following:

                      //V1= Val10 * (Val0 - Val1)/(Val2-Val1) +Val9 *(Val2-Val0)/(Val2-Val1);
                      mence->setText(QString::number( ( Val10 * (Val0 - Val1)/static_cast<double>(Val2-Val1) +Val9 *(Val2-Val0)/static_cast<double>(Val2-Val1) ) ));;
                      

                      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
                      • A Offline
                        A Offline
                        Alex42
                        wrote on last edited by
                        #41

                        @J-Hilk said in How to pass the parameters between the SIGNAL and SLOTS:

                        //V1= Val10 * (Val0 - Val1)/(Val2-Val1) +Val9 *(Val2-Val0)/(Val2-Val1);
                        mence->setText(QString::number( ( Val10 * (Val0 - Val1)/static_cast<double>(Val2-Val1) +Val9 *(Val2-Val0)/static_cast<double>(Val2-Val1) ) ));;

                        it's the same problem

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

                          you know in the same classe i don't have any problem , just when i try to read the values in another class, for exemple
                          when i do this in the same classe i have no probleme

                          connect (ui->lineEdit_17, SIGNAL (textChanged(QString)), this ,SLOT (encore_2(QString)));
                          void mesure::encore_2(QString)
                          {
                          
                          mence->setText(ui->lineEdit_17->text());
                          
                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            Alex42
                            wrote on last edited by
                            #43

                            @J-Hilk said in How to pass the parameters between the SIGNAL and SLOTS:

                            somewhere you're setting your mence->text to 0

                            it can be a private or public story because I declared my variables inside the calculate () slot

                            mrjjM 1 Reply Last reply
                            0
                            • A Alex42

                              @J-Hilk said in How to pass the parameters between the SIGNAL and SLOTS:

                              somewhere you're setting your mence->text to 0

                              it can be a private or public story because I declared my variables inside the calculate () slot

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

                              @Alex42

                              Go to where you define mence and right click and use "Find Usage" and it will show all places.

                              I cannot guess what it only send zero but we know signal works and we can send a string
                              so its a logical bug with mence and we cannot not spot it as we see only pieces and its easy to stare blind on own code so you dont either.

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

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

                                so its a logical bug with mence and we cannot not spot it as we see only pieces and its easy to stare blind on own code so you dont either.

                                @ mrjj, @J.Hilk, thank you for your help, so i will try to change my logic of coded, and i will take you know of the evolution

                                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