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. [Solved] Launching an exe independent of parent aplication?

[Solved] Launching an exe independent of parent aplication?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 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.
  • CAD_codingC Offline
    CAD_codingC Offline
    CAD_coding
    wrote on last edited by
    #1

    Hi,
    I want to launch an exe from my application, but I do not want to have any connection between them i.e. the child exe should be independent of the parent exe so that closing the parent exe does not close the child exe. I believe QProcess is used to launch an exe in Qt. So here is my code:

    //SessionManager subclasses QDialog
    @void SessionManager::on_resume_clicked()
    {
    QList <QListWidgetItem *> items = ui->sessionList->selectedItems();
    for(int i = 0; i < items.size(); i++)
    {
    QStringList args;
    args.append("-Session");
    args.append(items.at(i)->text());
    QString path = QApplication::arguments().at(0);
    QProcess *proc = new QProcess();//memory leak!!!!!!!
    proc->start(path, args);
    }
    close();
    }@

    As can be observed this fulfills my requirement but causes a memory leak. Now if I add this as the parent of proc in its contstructor then when I close my parent exe all child exe's get closed. I don't want this.
    Alternatively if I create proc in stack instead of heap then the child exe is not launched at all. It throws a warning that QProcess terminated before it was finished.
    Any guidance would be very helpful to me in this matter...

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      See startDetached:
      http://qt-project.org/doc/qt-5/qprocess.html#startDetached

      1 Reply Last reply
      0
      • CAD_codingC Offline
        CAD_codingC Offline
        CAD_coding
        wrote on last edited by
        #3

        Thanks for your help :)

        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