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. What is the correct way to initialize a QApplication without blocking in QApplication::exec()?
Forum Updated to NodeBB v4.3 + New Features

What is the correct way to initialize a QApplication without blocking in QApplication::exec()?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 273 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.
  • C Offline
    C Offline
    Carlos Delfino
    wrote on last edited by
    #1

    I need to open a window of a Qt application inside another application, I created a shared object that creates this window, however when I call the function that creates the window it blocks the QApplication.exec() function and this interferes with the entire remaining application.

    How do I get to display the window without blocking in QApplication::exec()?

    1 Reply Last reply
    0
    • jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by
      #2

      The easiest method is to run the Qt portion in its own thread, allowing QCoreApplication::exec() to block without interfering with the non-Qt portion of the program.

      At the other end of the spectrum QAbstractEventDispatcher enables integrating with another event loop in the same thread.

      Calling QCoreApplication::processEvents() can work, but as the documentation puts it:

      Use of this function is discouraged. Instead, prefer to move long operations out of the GUI thread into an auxiliary one and to completely avoid nested event loop processing. If event processing is really necessary, consider using QEventLoop instead.

      Asking a question about code? http://eel.is/iso-c++/testcase/

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved