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. Modal dialog blocks event loop on Mac OS
Forum Updated to NodeBB v4.3 + New Features

Modal dialog blocks event loop on Mac OS

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.0k 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.
  • Y Offline
    Y Offline
    yura-vel
    wrote on last edited by
    #1

    I have such behaviour in the app

    @QTimer timer;
    timer.connect( &timer, &QTimer::timeout, DO_SOMETHIG );
    timer.start( 0 );@

    then in somewhere:

    @QMessageBox dlg( ... );
    dlg.exec();@

    and after that the event loop freezes, until some event will be passed to the dlg. For example the mouse cursor hover the dialog window. Only in this case the app's event loop will thaw and DO_SOMETHIG from the above timer will be executed.

    This behaviour reproduced on MacOS. On Linux the event loop not freezes, DO_SOMETHIG executes as expected. On Windows this issue was not tested.

    In the search for solutions I found "this":http://stackoverflow.com/questions/9523311/undocumented-processeventsflag-enums-in-qt post. Here was told that modal dialogs uses special optimizations for mac that holds in file qcocoaeventdispatcher.mm. I researched this file and came to the conclusion that

    modal dialogs on Mac stops the execution of qt's event loop and transfers control to the NSApp while dialog executes. Only window's events from cocoa can awake qt's event loop.

    Am i right?

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

      Hi,

      Haven't checked yet but you use case can probably be solved by using QDialog's open function rather than exec

      Hope it helps

      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
      • Y Offline
        Y Offline
        yura-vel
        wrote on last edited by
        #3

        Unfortunately, I need to use exec(), because want to get feedback from user before continue execution. For example QMessageBox::Question.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sandy.martel
          wrote on last edited by
          #4

          To get the feedback from the dialog connect to its signals and "continue execution" there. You can connect a c++ closure if you want to stay in the same method.

          This is how it works.

          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