Qt WebKit - how to suppress JavaScript confirm method execution till reply from other process

  • Hi,

    I have reimplemented QWebPage::javaScriptConfirm() method and I would like to stop execution of this method till receiving event from external process. So I would like to implement such flow

    1. User trigger action -> WebKit -> WebPage -> send message over DBus to another process and wait till replay
    2. Anoter process replay -> DBus adaptor -> release wait condition and pull answer to web page

    Problem with I face is that QtWebKit as a GUI application needs to run in main thread, and I do wait on it. In result my process with WebKit freeze and I cannot get replay over DBus.

    Could you advice me how to solve such issue? How to wait on replay and do not freeze whole application. I already tried to move DBus Adaptor to other thread, but it does not work.

    Thanks in advance.

  • I found a way to solve my problem, but I am not sure if this is the perfect one.

    After sending message over DBus I am creating internal event loop, like this

    QEventLoop loop;
    QTimer timer;

    connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
    connect(this, SIGNAL(replayReceived()), &loop, SLOT(quit()));


    if (timer.isActive) //replay received before timer
    else //timer elapsed, no replay from client

    Such construction allows process to continue processing of main event loop and to keep certain method in wait condition realized by event loop.

    Now if user does or dose not replay I can handle it in if condition.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.