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. variable transfer between two forms
Forum Update on Monday, May 27th 2025

variable transfer between two forms

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 554 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.
  • F Offline
    F Offline
    fkaraokur
    wrote on last edited by
    #1

    Hello. I want to send the data in a variable from the first form to the second form. I studied many topics in the forum, but did not understand anything. Can you please help?

    jsulmJ JonBJ 2 Replies Last reply
    0
    • F fkaraokur

      Hello. I want to send the data in a variable from the first form to the second form. I studied many topics in the forum, but did not understand anything. Can you please help?

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

      @fkaraokur You can use signals/slots for that: https://doc.qt.io/qt-5/signalsandslots.html

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

      F 1 Reply Last reply
      3
      • jsulmJ jsulm

        @fkaraokur You can use signals/slots for that: https://doc.qt.io/qt-5/signalsandslots.html

        F Offline
        F Offline
        fkaraokur
        wrote on last edited by
        #3

        @jsulm said in variable transfer between two forms:

        @fkaraokur You can use signals/slots for that: https://doc.qt.io/qt-5/signalsandslots.html

        I studied here but could not figure out.

        jsulmJ 1 Reply Last reply
        0
        • F fkaraokur

          @jsulm said in variable transfer between two forms:

          @fkaraokur You can use signals/slots for that: https://doc.qt.io/qt-5/signalsandslots.html

          I studied here but could not figure out.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #4

          @fkaraokur Define a signal in the form class wich wants to expose that variable, in the other form define a slot and do:

          connect(form1, &Form1::someSignal, form2, &Form2::someSlot);
          

          If you then want to send that variable value to the other form simply emit the signal:

          emit someSignal(variable);
          

          If you have problems with that please ask more specific questions.
          Signals/slots are one of the fundamental concepts in Qt which have to learn and understand if you want to use Qt.

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

          F 1 Reply Last reply
          2
          • F fkaraokur

            Hello. I want to send the data in a variable from the first form to the second form. I studied many topics in the forum, but did not understand anything. Can you please help?

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

            @fkaraokur said in variable transfer between two forms:

            send the data in a variable from the first form to the second form

            Solution also depends on just what/when you mean by this? For example, do you only want to initialise one form with data from another form? Is the other form a QDialog? Do you want get the data from a dialog only after the used has exited from it?

            1 Reply Last reply
            0
            • jsulmJ jsulm

              @fkaraokur Define a signal in the form class wich wants to expose that variable, in the other form define a slot and do:

              connect(form1, &Form1::someSignal, form2, &Form2::someSlot);
              

              If you then want to send that variable value to the other form simply emit the signal:

              emit someSignal(variable);
              

              If you have problems with that please ask more specific questions.
              Signals/slots are one of the fundamental concepts in Qt which have to learn and understand if you want to use Qt.

              F Offline
              F Offline
              fkaraokur
              wrote on last edited by
              #6

              @jsulm said in variable transfer between two forms:

              @fkaraokur Define a signal in the form class wich wants to expose that variable, in the other form define a slot and do:

              connect(form1, &Form1::someSignal, form2, &Form2::someSlot);
              

              If you then want to send that variable value to the other form simply emit the signal:

              emit someSignal(variable);
              

              If you have problems with that please ask more specific questions.
              Signals/slots are one of the fundamental concepts in Qt which have to learn and understand if you want to use Qt.

              connect(form1, &Form1::someSignal, form2, &Form2::someSlot);
              Where should I write this expression?

              jsulmJ 1 Reply Last reply
              0
              • F fkaraokur

                @jsulm said in variable transfer between two forms:

                @fkaraokur Define a signal in the form class wich wants to expose that variable, in the other form define a slot and do:

                connect(form1, &Form1::someSignal, form2, &Form2::someSlot);
                

                If you then want to send that variable value to the other form simply emit the signal:

                emit someSignal(variable);
                

                If you have problems with that please ask more specific questions.
                Signals/slots are one of the fundamental concepts in Qt which have to learn and understand if you want to use Qt.

                connect(form1, &Form1::someSignal, form2, &Form2::someSlot);
                Where should I write this expression?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @fkaraokur said in variable transfer between two forms:

                Where should I write this expression?

                Where you have both form instances.

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

                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