QApplication In Non-Main Thread

前端 未结 6 609
旧时难觅i
旧时难觅i 2020-12-05 08:18

I need to exec() a QApplication in a thread that is not main (my GUIs must be plugins that can be dynamically loaded and unloaded at runtime, so I have no access to the main

6条回答
  •  情话喂你
    2020-12-05 08:58

    A good solution is found in: git@github.com:midjji/convenient_multithreaded_qt_gui.git

    then its just e.g.

    run_in_gui_thread(new RunEventImpl([](){
            QMainWindow* window=new QMainWindow();
            window->show();
        }));
    

    or whatever code you wish to run in the gui thread.

    callable from any thread, at any time, while taking care of setting things up for you in the bg.

提交回复
热议问题