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. Bring Widget To front
Forum Updated to NodeBB v4.3 + New Features

Bring Widget To front

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 3.8k Views 2 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.
  • S Offline
    S Offline
    Shahina
    wrote on last edited by Shahina
    #1

    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

    A 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What do you run in your QProcess ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • S Shahina

        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

        A Offline
        A Offline
        ambershark
        wrote on last edited by
        #3

        @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).

        My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

        S 1 Reply Last reply
        1
        • SGaistS SGaist

          Hi,

          What do you run in your QProcess ?

          S Offline
          S Offline
          Shahina
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • A ambershark

            @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).

            S Offline
            S Offline
            Shahina
            wrote on last edited by
            #5

            @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.

            A 1 Reply Last reply
            0
            • S Shahina

              @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.

              A Offline
              A Offline
              ambershark
              wrote on last edited by
              #6

              @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.

              My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

              1 Reply Last reply
              1

              • Login

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