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 is QEventLoop processed ? In what sequence ?
Forum Updated to NodeBB v4.3 + New Features

How is QEventLoop processed ? In what sequence ?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 522 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.
  • J Offline
    J Offline
    JanaHus
    wrote on last edited by
    #1

    I am using the attached code as a part of standard C while loop to actually print the debug and texttEdit messages "on the fly" - not only AFTER the entire while loop is finished.

    I understand that QEventLoop "runs inside" Qt application loop, hence has to be started and then terminated.
    The QTimer::singleShot is the timer and its SLOT(quit()) returns the processing to main application loop - stops the QEventLoop .

    I do not understand when does the output test message gets processed .
    I understand it is yet another "event"....

    Does it get processed before the loop.exec();?

    I would appreciate if somebody could explain to me the timing sequence of the code . To me it looks that all the code AFTER QEventLoop loop; and BEFORE loop.exec(); could be called
    QEventLoop setup.

    Help would be greatly appreciated.
    Thanks.

        int LoopDelay = 2000;
        {
            // declare QEventLoop ??
            QEventLoop loop;
            // setup loop timer and return SLOT to main application loop 
            QTimer::singleShot(LoopDelay , &loop, SLOT(quit()));
            // output test message   
            text = " \t\t RUn QEventLoop  delay      ";
            text += QString::number(LoopDelay );
            m_ui->textEdit_13->append( text);
            // execute QEventLoop
            loop.exec();
        }
        text = " \t\t QEventLoop  delay  finished     ";
        text += QString::number(LoopDelay );
        m_ui->textEdit_13->append( text);
    
    C 1 Reply Last reply
    1
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Oh, new user name ...

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      C 1 Reply Last reply
      1
      • J JanaHus

        I am using the attached code as a part of standard C while loop to actually print the debug and texttEdit messages "on the fly" - not only AFTER the entire while loop is finished.

        I understand that QEventLoop "runs inside" Qt application loop, hence has to be started and then terminated.
        The QTimer::singleShot is the timer and its SLOT(quit()) returns the processing to main application loop - stops the QEventLoop .

        I do not understand when does the output test message gets processed .
        I understand it is yet another "event"....

        Does it get processed before the loop.exec();?

        I would appreciate if somebody could explain to me the timing sequence of the code . To me it looks that all the code AFTER QEventLoop loop; and BEFORE loop.exec(); could be called
        QEventLoop setup.

        Help would be greatly appreciated.
        Thanks.

            int LoopDelay = 2000;
            {
                // declare QEventLoop ??
                QEventLoop loop;
                // setup loop timer and return SLOT to main application loop 
                QTimer::singleShot(LoopDelay , &loop, SLOT(quit()));
                // output test message   
                text = " \t\t RUn QEventLoop  delay      ";
                text += QString::number(LoopDelay );
                m_ui->textEdit_13->append( text);
                // execute QEventLoop
                loop.exec();
            }
            text = " \t\t QEventLoop  delay  finished     ";
            text += QString::number(LoopDelay );
            m_ui->textEdit_13->append( text);
        
        C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        @JanaHus said in How is QEventLoop processed ? In what sequence ?:

        Does it get processed before the loop.exec();?

        Yes, of course. The internal state of the UI widget object will be updated and an update of the screen, if required, will be scheduled.

        Does it update the screen? No. That will occur only when your code enters the Qt event loop; whether that is a local QEventLoop or the main application loop.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JanaHus
          wrote on last edited by
          #4

          update of the screen, if required, will be scheduled.
          OK. that answered my question. Thanks.

          1 Reply Last reply
          0
          • J JanaHus has marked this topic as solved on
          • Christian EhrlicherC Christian Ehrlicher

            Oh, new user name ...

            C Offline
            C Offline
            ChrisW67
            wrote on last edited by
            #5

            @Christian-Ehrlicher said in How is QEventLoop processed ? In what sequence ?:

            Oh, new user name ...

            Should I ask? My replies usually do not result in banning *<8O)

            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