Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Open Process from qml

Open Process from qml

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 1.3k Views 1 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.
  • L Offline
    L Offline
    Leon_2001
    wrote on last edited by
    #1

    Hi everyone,

    I 'm creating some kind of launcher for applications. Therefore I wrote a function to start a process.

    void ApplicationManager::startApplication(const QString& program, const QStringList& arguments) {
      QProcess* myProcess = new QProcess(this);
      myProcess->startDetached(program, arguments);
    }
    

    I created in qml an instance of ApplicationManager and call this function. it works.
    The thing is I want to have control over the process. So if I hit for example Ctrl+Y I want the application to be closed. And the launcher should be displayed again.
    How can I achieve this?

    JonBJ 1 Reply Last reply
    0
    • L Leon_2001

      Hi everyone,

      I 'm creating some kind of launcher for applications. Therefore I wrote a function to start a process.

      void ApplicationManager::startApplication(const QString& program, const QStringList& arguments) {
        QProcess* myProcess = new QProcess(this);
        myProcess->startDetached(program, arguments);
      }
      

      I created in qml an instance of ApplicationManager and call this function. it works.
      The thing is I want to have control over the process. So if I hit for example Ctrl+Y I want the application to be closed. And the launcher should be displayed again.
      How can I achieve this?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Leon_2001
      Ctrl+Y for close application? Well, up to you. Where do you mean you press the Ctrl+Y: in the subprocess's window (assuming it has one) or the parent process's? Anyway, if you really want the sub-process to be "closed" from the parent process, you'll want to recognise the keys in the parent and then probably https://doc.qt.io/Qt-5/qprocess.html#terminate or more likely in your case https://doc.qt.io/Qt-5/qprocess.html#kill it, not ideal but looks like what you will require.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Leon_2001
        wrote on last edited by
        #3

        Can't get key input from the other application I suppose as I have not written them.

        Is it maybe possible to kind of embedded the applications in my application? Like to open firefox in a ApplicationWindow. Then I would have full control and could implement a shortcut for returning to the launcher or open a menu where I can do some settings. I know I could do things like this by defining global shortcuts on my linux machine, but then they are global, which is not what I want.

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

          Hi,

          The startDetached overload you use is static so your myProcess creation just uses memory for nothing. If you want to stop that application cleanly, you should get its PID. With all the caveats explained in the documentation to take into account.

          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