Bring Widget To front



  • Hi to all. My widget is not coming front if I run QProcess before showing widget. My code is

    main.cpp :
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    Widget w;
    if( ... ) // check some condition
    {
    QProcess *process = new QProcess();
    process->start("application.exe", QStringList());
    QObject::connect(process, SIGNAL(finished(int)), &w, SLOT(finish(int)));
    } else {
    w.show();
    }
    return a.exec();
    }

    widget.cpp :

    void Widget::finish(int)
    {
    this->show();
    }

    It runs the application.exe using QProcess. If I quit the QProcess application, It shows widget.ui but not in front, it goes to back of all external application which currently running. So I need to show widget in front after closing QProcess application. And also I have tried , raise(), show, ActiveWindow(). It blink oly the icon in tool bar and also used Qt::WindowStaysOnTopHint, it always bring widget to front. Thanks


  • Lifetime Qt Champion

    Hi,

    What do you run in your QProcess ?


  • Moderators

    @Shahina Sounds like whatever is running in the QProcess takes the foreground application spot for the OS.

    So your Qt application that started it is no longer the foreground process. Therefore when you show your widget it shows as part of your process rather than the foreground process (which you started but may or may not be running any more).

    You can set your process to be the active one, or you can force your widget to the top (but I wouldn't necessarily recommend that).



  • @SGaist : I am running a separate Qt application in QProcess.



  • @ambershark : Thanks for the reply. Yes you are right. But i need to show widget in finish slot of QProcess. Thatswhy i am trying the widget to bring top. I have used Qt::WindowsStayOnTopHint. It bring always widget as top. Please suggest any other method to bring widget top.


  • Moderators

    @Shahina Here ya go, this should help you understand the problem and there is a solution in it as well but it is windows specific.

    http://stackoverflow.com/questions/5919928/qt-need-to-bring-qt-application-to-foreground-called-from-win32-application

    I don't know of a good Qt solution for you. What you are describing is how window managers are meant to work. In it's mind your application is no long the foreground app and shouldn't be able to bring windows to the foreground without using an always on top type of setting. Which still wouldn't give you focus it would just force your window on top. Not the same thing.


Log in to reply
 

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