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. How to insert double quotes in the contents of a QString?
Forum Updated to NodeBB v4.3 + New Features

How to insert double quotes in the contents of a QString?

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

    I have an option in my GUI that I select a program I want to open and keep his path into a QString.
    To open it I need to insert double quotes because the prompt only opens so.
    How to insert double quotes in a QString?
    @ QProcess pr1;
    QStringList argss;
    argss << "D:\example\progam1\temp\esseaqui" << "-P" << "pythoon2.py";
    pr1.start(_version249b, argss); //_version249b is the string that I want to insert double quotes in your content

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

      Hi,

      Do you mean double quotes or backslashes ?

      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
      • N Offline
        N Offline
        Neutrox
        wrote on last edited by
        #3

        I just found out I need backslash too. So I need to know the two (quotes and backslashes)

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

          " and \\ to have a a double quote and a double backslash in your string.

          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
          • N Offline
            N Offline
            Neutrox
            wrote on last edited by
            #5

            ok, but how I add that in my string?

            1 Reply Last reply
            0
            • jerome_isAviableJ Offline
              jerome_isAviableJ Offline
              jerome_isAviable
              wrote on last edited by
              #6

              @
              QString word = "outside..."inside double quote"...outside";
              @
              or better more:
              @
              QString word = tr("outside..."inside my double quotes"...outside");
              @
              (tr() serve after for translation of everything string style inside tr() ).

              in your situation:
              @
              QProcess pr1;
              QStringList argss;
              argss << ""D:\example\progam1\temp\esseaqui"" << ""-P"" << ""pythoon2.py"";
              pr1.start(_version249b, argss);
              @

              there is also some other way to add these doubles quote automatically after include datas in you QStringList... with QString::insert method at render time, or, for have it definitly, between the entri and the render by a foreach loop with this insertion inside... there is many ideas for do it...
              depend of what you really need.

              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