Qt: Is there notification when event loop starts?

前端 未结 3 2087
一向
一向 2021-02-19 00:19

I have a Qt application with this kind of main()...

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    MainWindow   mainWin;

    ... A sep         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-19 00:32

    You can send a signal to your window before the exec() call. This will place an entry in app's signal queue. When exec() is running, the signal will be delivered and your window will know that the event loop is running.

    A simple way would be to use QTimer::singleShot(0, &mainWin, SLOT(onEventLoopStarted())); which connects to a custom slot of your window class.

提交回复
热议问题