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 use quotation marks in QStrings?
Qt 6.11 is out! See what's new in the release blog

How to use quotation marks in QStrings?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 812 Views 3 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.
  • B Offline
    B Offline
    bartvrossum
    wrote on last edited by
    #1

    Hi,

    I was wondering:
    When I use something like this, how do I have it get quotation marks in the output?

      qDebug() << "I want this to display in quotation marks:\n";
    

    Like, this doesn't work:

      qDebug() << ""I want this to display in quotation marks:\n"";
    

    Thanks in advance!

    Pl45m4P 1 Reply Last reply
    0
    • B bartvrossum

      Hi,

      I was wondering:
      When I use something like this, how do I have it get quotation marks in the output?

        qDebug() << "I want this to display in quotation marks:\n";
      

      Like, this doesn't work:

        qDebug() << ""I want this to display in quotation marks:\n"";
      

      Thanks in advance!

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @bartvrossum

      Hi,

      escape it with \.

      qDebug() << "\"Foo\"";


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      4
      • Chris KawaC Online
        Chris KawaC Online
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by Chris Kawa
        #3

        " is a special character inside a string, so, like with \n you need to escape it with \:

        qDebug() << "\"I want this to display in quotation marks:\n\"";
        

        or with C++11 you can use it unescaped enclosed in R"( and )"

        qDebug() << R"("I want this to display in quotation marks:
        ")";
        
        1 Reply Last reply
        4

        • Login

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