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 transfer data sequence between forms in Qt
Forum Updated to NodeBB v4.3 + New Features

How to transfer data sequence between forms in Qt

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

    Assume I have 2 forms in a Qt application. I need to transfer data between 2 forms many times so I used the loop to do this. I just wanna get result from Form 2 before Form 1 is continue to loop. This is my desired intention:

    !http://i249.photobucket.com/albums/gg220/HienBoo/form2.png(Transfer data)!

    When I used the loop normally, the loop began at i = 1 and sent data to Form 2. Before Form 2 returned result to Form 1, Form 1 was continue to send data with i = 2.

    Could you give me some solutions?

    Thanks!

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      Hi, can you tell us which problem you have encountered?

      @
      for (int i=0; i<3; ++i)
      ret = form2.doSomething();
      @

      1 Reply Last reply
      0
      • M Offline
        M Offline
        monsingh
        wrote on last edited by
        #3

        for(int i = 0; i < 5; i++)
        {
        callToFunction2();
        qApp->processEvents();
        }

        processevents is wait till we get the restult from form 2.

        hope this will help.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          [quote author="monsingh" date="1375164656"]for(int i = 0; i < 5; i++)
          {
          callToFunction2();
          qApp->processEvents();
          }

          processevents is wait till we get the restult from form 2.
          [/quote]

          No it won't, processEvent will just process the pending events.

          Like 1+1=2 suggested, all the processing should be done before the function returns

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            monsingh
            wrote on last edited by
            #5

            Hi SGaist,

            try this small program: we get the order of execution.

            write the for loop in construcor

            for(int i = 0; i < 5; i++)
            {
            qDebug() << callToFunction2(i);
            qApp->processEvents();
            }

            int MainWindow::callToFunction2(int i)
            {
            qDebug()<< "order :" << ++i;
            return 5;
            }

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Wait, we are not understanding each-other right.

              Do you mean that processEvent will be called after callToFunction2 has returned ? In that case I agree

              PS: please enclose your code with coding tags to make it readable

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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