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. QProcess signal for when QMainWindow is on screen
Forum Updated to NodeBB v4.3 + New Features

QProcess signal for when QMainWindow is on screen

Scheduled Pinned Locked Moved Unsolved General and Desktop
qprocessqmainwindow
6 Posts 2 Posters 2.5k 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
    skebanga
    wrote on last edited by
    #1

    I have a launcher application which displays icons of a configured list of applications.

    When the user clicks on an icon, a QProcess launches the application.

    For visual feedback, I want to display a wait cursor from the time when the user selects an icon, until the requested app's QMainWindow is on-screen.

    void RocketLauncher::onItemSelect(QListWidgetItem* item)
    {
        QApplication::setOverrideCursor(Qt::WaitCursor);
    
        QProcess* process = new QProcess();
        QObject::connect(process, &QProcess::started, [&]()
                {
                    QApplication::restoreOverrideCursor(); // this fires well before the child process's main window is displayed
                });
    
        process->start(appConfig(item).cmd());
    }
    

    The problem that I'm having is that the QProcess::started signal fires immediately, but it still takes some time for the child process's QMainWindow to show up on-screen.

    As such, my call to QApplication::restoreOverrideCursor() executes immediately, and there is no visual cue to the user that the application is still being launched.

    Is there some way I can get signalled that the QMainWindow is on screen?

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

      Hi,

      Unless these application somehow signals that they are shown, there's no way for QProcess to know that.

      Note that you have a memory leak here. You never delete the QProcess objects attached to the application you started.

      If it's not something you want to handle, then you can also call startDetached, however there's no communication possible when starting a process like that.

      Hope it helps

      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
      • SGaistS SGaist

        Hi,

        Unless these application somehow signals that they are shown, there's no way for QProcess to know that.

        Note that you have a memory leak here. You never delete the QProcess objects attached to the application you started.

        If it's not something you want to handle, then you can also call startDetached, however there's no communication possible when starting a process like that.

        Hope it helps

        S Offline
        S Offline
        skebanga
        wrote on last edited by
        #3

        @SGaist - thanks for your input.

        I found this document from freedesktop.org regarding a Startup notification protocol

        The précis reads:

        This document specifies a mechanism allowing a desktop environment to
        track application startup, to provide user feedback and other
        features.

        There is something in the Gnome docs about using "StartupNotify" in launchers.

        Also, in this SO question there is something about "X-KDE-StartupNotify" and its interaction with QApplication.

        I would expect there is something built into QApplication, but I'm not sure what to search for?

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

          You should take a look at the xcb platform plugin.

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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            skebanga
            wrote on last edited by
            #5

            @SGaist said:

            xcb platform

            Wow - that's pretty low-level!

            I've managed to find my way here: http://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms/xcb

            TBH at this point I'm getting a bit out of my depth.

            Any suggestions on examples of this code being used somewhere? Perhaps in some KDE app or some such?

            TIA

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

              Basically, it's not a part of Qt that you access directly. It's part of the platform plugins that abstracts away the differences between the various supported OSs.

              The best I can recommend is to contact the KDE folks about how the startup notification is handled by them.

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

              1 Reply Last reply
              0

              • Login

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