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. pass variable inside of double quote for use in QProcess

pass variable inside of double quote for use in QProcess

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 724 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.
  • S Offline
    S Offline
    saeid0034
    wrote on last edited by
    #1

    Hi i now its not a good question but i cant find anyway to do this
    i have this code for extract a file in Temp folder from Qt resource

        QFile PAKList(":/test/list.txt");
        QTemporaryFile *NewTempFile = QTemporaryFile::createNativeFile(PAKList);
        QString arg = NewTempFile->fileName();
    

    i want to use arg inside QProcess as a argument of a extrnal program, problem is, its possible some user have space in there username, so the arg is look like this when a space is in file location C:/Users/user test/AppData/Local/Temp/File-X.cjDgQO and as you know cmd program doesnt allow space in file address, so i want to add double quote to arg, but i dont know how can i do this job in a variable.
    anyone can help

    1 Reply Last reply
    0
    • S saeid0034

      any help?
      how can i Put arg into double quote

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

      @saeid0034

      how can i Put arg into double quote

      "-list=\"" + arg + "\""

      Whether this will do what your exe expects I don't know.

      1 Reply Last reply
      3
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        I don't see a problem when using QProcess here.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        S 1 Reply Last reply
        1
        • Christian EhrlicherC Christian Ehrlicher

          I don't see a problem when using QProcess here.

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

          @Christian-Ehrlicher said in pass variable inside of double quote for use in QProcess:

          I don't see a problem when using QProcess here.

             QProcess BigPAKC;
              BigPAKC.start("some.exe", QStringList() << "d:/output/out.file" << "-list=" + arg << "-compress");
          

          this code work when there is no space in arg, but when there is its not work, so i need to add "" to arg

          1 Reply Last reply
          0
          • S Offline
            S Offline
            saeid0034
            wrote on last edited by
            #4

            any help?
            how can i Put arg into double quote

            JonBJ 1 Reply Last reply
            0
            • S saeid0034

              any help?
              how can i Put arg into double quote

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

              @saeid0034

              how can i Put arg into double quote

              "-list=\"" + arg + "\""

              Whether this will do what your exe expects I don't know.

              1 Reply Last reply
              3

              • Login

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