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::start(i) - i is a file with spaces
Forum Updated to NodeBB v4.3 + New Features

QProcess::start(i) - i is a file with spaces

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 392 Views
  • 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.
  • I Offline
    I Offline
    islamaf
    wrote on last edited by
    #1

    Hello all,

    I am trying to pass a .exe file containing spaces such as te st2.exe to QProcess::start().
    However, the process doesn't actually open the file even though if the .exe file is without spaces such as test3.exe, it runs perfectly.

    Example code:

    QDir directory = QDir::currentPath();
    QStringList list = directory.entryList(QStringList() << "*.exe" << "*.EXE", QDir::Files);
    /* list contains: ("te st2.exe", "test3.exe") */
    for(auto& i : list){
    QProcess p;
    p.start(i);
    p.waitForFinished();
    QString output = p.readAllStandardOutput();
    }
    

    Now, my question is how to run a file having a name which contains spaces?

    All ideas are appreciated! Thanks!

    B jsulmJ 2 Replies Last reply
    0
    • I islamaf

      Hello all,

      I am trying to pass a .exe file containing spaces such as te st2.exe to QProcess::start().
      However, the process doesn't actually open the file even though if the .exe file is without spaces such as test3.exe, it runs perfectly.

      Example code:

      QDir directory = QDir::currentPath();
      QStringList list = directory.entryList(QStringList() << "*.exe" << "*.EXE", QDir::Files);
      /* list contains: ("te st2.exe", "test3.exe") */
      for(auto& i : list){
      QProcess p;
      p.start(i);
      p.waitForFinished();
      QString output = p.readAllStandardOutput();
      }
      

      Now, my question is how to run a file having a name which contains spaces?

      All ideas are appreciated! Thanks!

      B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2

      @islamaf try

      p.start(i, QStringList());
      
      I 1 Reply Last reply
      3
      • B Bonnie

        @islamaf try

        p.start(i, QStringList());
        
        I Offline
        I Offline
        islamaf
        wrote on last edited by
        #3

        @Bonnie Thanks a lot! This does the job :D

        1 Reply Last reply
        0
        • I islamaf

          Hello all,

          I am trying to pass a .exe file containing spaces such as te st2.exe to QProcess::start().
          However, the process doesn't actually open the file even though if the .exe file is without spaces such as test3.exe, it runs perfectly.

          Example code:

          QDir directory = QDir::currentPath();
          QStringList list = directory.entryList(QStringList() << "*.exe" << "*.EXE", QDir::Files);
          /* list contains: ("te st2.exe", "test3.exe") */
          for(auto& i : list){
          QProcess p;
          p.start(i);
          p.waitForFinished();
          QString output = p.readAllStandardOutput();
          }
          

          Now, my question is how to run a file having a name which contains spaces?

          All ideas are appreciated! Thanks!

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @islamaf Try to put executable file name into "":

          "\"te st2.exe\""
          

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          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