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. call a function in another function
QtWS25 Last Chance

call a function in another function

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 829 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.
  • Z Offline
    Z Offline
    Zunneh
    wrote on last edited by
    #1

    Hello guys , i created a new class and i created 2 functions ( moveLine and moveH) now i want to call moveLine in moveH , can someone help me ?thanks

    0_1551689739938_Capture d’écran 2019-03-04 à 09.50.53.png

    0_1551689754667_Capture d’écran 2019-03-04 à 09.50.46.png

    my english is average, please use simple words and try to be the most explicit, thank you

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

      Hi
      move test and testa to class definition.
      then you can use it for the call
      moveLine(test);
      moveLine(testa);

      to be clear

      in tabWidget .h

      class tabWidget : xxxxxx {
      ...
      QTextEdit *test;
      QTextEdit *testa;
      }

      and then in .cpp
      you new them
      testa=new QTextEdit(this);
      ...

      and PLEASE post real code and not images. its annoying to use for answering.

      Z 2 Replies Last reply
      5
      • mrjjM mrjj

        Hi
        move test and testa to class definition.
        then you can use it for the call
        moveLine(test);
        moveLine(testa);

        to be clear

        in tabWidget .h

        class tabWidget : xxxxxx {
        ...
        QTextEdit *test;
        QTextEdit *testa;
        }

        and then in .cpp
        you new them
        testa=new QTextEdit(this);
        ...

        and PLEASE post real code and not images. its annoying to use for answering.

        Z Offline
        Z Offline
        Zunneh
        wrote on last edited by
        #3

        @mrjj Thank you dude , i will post the code next time

        my english is average, please use simple words and try to be the most explicit, thank you

        1 Reply Last reply
        1
        • mrjjM mrjj

          Hi
          move test and testa to class definition.
          then you can use it for the call
          moveLine(test);
          moveLine(testa);

          to be clear

          in tabWidget .h

          class tabWidget : xxxxxx {
          ...
          QTextEdit *test;
          QTextEdit *testa;
          }

          and then in .cpp
          you new them
          testa=new QTextEdit(this);
          ...

          and PLEASE post real code and not images. its annoying to use for answering.

          Z Offline
          Z Offline
          Zunneh
          wrote on last edited by
          #4

          @mrjj my question was i want to call the function

               moveLine(QLineEdit *test) 
          

          in another function her in

              moveH() //whithout argument
          

          when i call moveH() in my main program he will call

                 moveLine(QLineEdit *test)
          

          my english is average, please use simple words and try to be the most explicit, thank you

          mrjjM 1 Reply Last reply
          0
          • Z Zunneh

            @mrjj my question was i want to call the function

                 moveLine(QLineEdit *test) 
            

            in another function her in

                moveH() //whithout argument
            

            when i call moveH() in my main program he will call

                   moveLine(QLineEdit *test)
            
            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #5

            @Zunneh
            Hi
            Why do you want to give it a QLineEdit when you call it from
            main program ?
            It seems a bit messy.
            Also what is the lineEdit ? You have some in tabWidget so i guess
            a good question is what you plan to do with them?

            Z 1 Reply Last reply
            0
            • mrjjM mrjj

              @Zunneh
              Hi
              Why do you want to give it a QLineEdit when you call it from
              main program ?
              It seems a bit messy.
              Also what is the lineEdit ? You have some in tabWidget so i guess
              a good question is what you plan to do with them?

              Z Offline
              Z Offline
              Zunneh
              wrote on last edited by Zunneh
              #6

              @mrjj
              i created a QLineEdit in main program to move it with moveLine , now i want to add some conditions in moveH to call

                       MoveLine(QLineEdit *test ) 
              

              my objective is to minimise the code , i created the method moveLine(QLineEdit *test) and i want to call it in another methods ,
              so my question is , how to call a method in another method in the same class ?

              my english is average, please use simple words and try to be the most explicit, thank you

              mrjjM 1 Reply Last reply
              0
              • Z Zunneh

                @mrjj
                i created a QLineEdit in main program to move it with moveLine , now i want to add some conditions in moveH to call

                         MoveLine(QLineEdit *test ) 
                

                my objective is to minimise the code , i created the method moveLine(QLineEdit *test) and i want to call it in another methods ,
                so my question is , how to call a method in another method in the same class ?

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

                @Zunneh
                hi

                so function1 get a lineEdit
                and later when you call function2, it must know the line
                you got in function1?

                If you need to remember the QLineEdit, you must store it in the class.

                • how to call a method in another method in the same class ?
                  you just call it. nothing extra. simply call it.
                1 Reply Last reply
                2

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved