Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Form show is not immediate

Form show is not immediate

Scheduled Pinned Locked Moved Mobile and Embedded
10 Posts 2 Posters 2.4k 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.
  • A Offline
    A Offline
    amolypalshetkar
    wrote on last edited by
    #1

    Application has many form.

    fun1(){

    Code A
    form1.show();
    Code B
    }

    My problem is that until code B is not finished form1 is not show. Please tell me the solution for this.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Move Code B to another function and invoke it with a delay (for example, using signals and slots, or meta objects).

      Alternatively, you can insert this line between show() and Code B:
      @
      qApp->processEvents();
      @

      (Z(:^

      1 Reply Last reply
      0
      • A Offline
        A Offline
        amolypalshetkar
        wrote on last edited by
        #3

        My problem is that form should be shown first and in background the Code B should get executed.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          amolypalshetkar
          wrote on last edited by
          #4

          #include<QDialog>
          fun1(){
          qDebug() << “Code A”;
          w.show(); // Should display wait screen dialog
          /* My problem is that wait screen is not shown immediately but shown after code B is executed. */
          qDebug() << “Code B”; // Perform some calculations and read write to I/O device.
          w.hide(); // Hide wait screen dialog
          }
          [quote author="sierdzio" date="1393410839"]Move Code B to another function and invoke it with a delay (for example, using signals and slots, or meta objects).

          Alternatively, you can insert this line between show() and Code B:
          @
          qApp->processEvents();
          @[/quote]

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            I recommend using the asynchronous approach (signals and slots). It makes the design clearer and avoids some problems when compared to sequential kind of thinking your snippet shows.

            Also, please wrap your code in '@' tags.

            (Z(:^

            1 Reply Last reply
            0
            • A Offline
              A Offline
              amolypalshetkar
              wrote on last edited by
              #6

              Tried the asynchronous method but still the wait screen wont show up before code B gets executed.

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                Do you get any error messages? Is the event loop running? Are you using Qt::QueuedConnection for your signal-slot connection?

                (Z(:^

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  amolypalshetkar
                  wrote on last edited by
                  #8

                  No i am not getting any error message. And i am not using Qt::QueuedConnection for my signal and slot.

                  1 Reply Last reply
                  0
                  • sierdzioS Offline
                    sierdzioS Offline
                    sierdzio
                    Moderators
                    wrote on last edited by
                    #9

                    Try it, then. Or invoke your slot using QTimer::singleShot().

                    (Z(:^

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      amolypalshetkar
                      wrote on last edited by
                      #10

                      Dear Sierdzio,

                      qApp->processEvents();

                      Was the solution to my problem.

                      Many thanks.

                      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