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 function from one form in another
Forum Updated to NodeBB v4.3 + New Features

Call function from one form in another

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 495 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.
  • S Offline
    S Offline
    Shivam Sharma
    wrote on last edited by
    #1

    Hello

    I have a function that generates values in one form. Now i want to call that function on a second form to display on the second ui. Can anyone tell me if there is a method to do this?

    jsulmJ 1 Reply Last reply
    0
    • S Shivam Sharma

      Hello

      I have a function that generates values in one form. Now i want to call that function on a second form to display on the second ui. Can anyone tell me if there is a method to do this?

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Shivam-Sharma said in Call function from one form in another:

      Can anyone tell me if there is a method to do this?

      The correct method in Qt are signals/slots: https://doc.qt.io/qt-5/signalsandslots.html
      Connect signal from first form to a slot in second form. And emit the signal in first form if it generated something.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      3
      • S Offline
        S Offline
        Shivam Sharma
        wrote on last edited by
        #3

        Will try this and let you knwo.

        1 Reply Last reply
        0
        • jsulmJ jsulm

          @Shivam-Sharma said in Call function from one form in another:

          Can anyone tell me if there is a method to do this?

          The correct method in Qt are signals/slots: https://doc.qt.io/qt-5/signalsandslots.html
          Connect signal from first form to a slot in second form. And emit the signal in first form if it generated something.

          S Offline
          S Offline
          sambills
          Banned
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • S Offline
            S Offline
            Shivam Sharma
            wrote on last edited by
            #5

            Not being able to connect. Have tried how much I could, but not being able to figure it out. Could someone help, please.

            JonBJ 1 Reply Last reply
            0
            • S Shivam Sharma

              Not being able to connect. Have tried how much I could, but not being able to figure it out. Could someone help, please.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @Shivam-Sharma
              Show code attempt.

              At the end of the day won't it be:

              connect(form1_instance, &form1_signal, form2_instance, &form2_slot);
              

              You will need to write that code in a module which includes both form1.h & form2.h. That might potentially be either form1.cpp or form2.cpp, or perhaps you have a mainwindow.cpp which includes both form1.h & form2.h.

              1 Reply Last reply
              1

              • Login

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