Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. How to add newline to a QString? - repost
Qt 6.11 is out! See what's new in the release blog

How to add newline to a QString? - repost

Scheduled Pinned Locked Moved Unsolved C++ Gurus
3 Posts 3 Posters 1.1k 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    Re: How to add newline to a QString?

    The attached C code FAILS to insert "\n" or "\t" when the main variable is QString. ( string concatenation)

           QString text = "VERIFY SUCCESS OK allocated extended server socket ";
                text += "\n";
                text += QString::number(server_socket);
                text += "\n";
                text += Q_FUNC_INFO;
                text += " @ line ";
                text += QString::number(__LINE__);
                qDebug() << text;
    

    Here is the actual code output

    "int MainWindow_C_CODE_FORM::C_CODE_Scanner() @ line 211"
    "VERIFY SUCCESS OK allocated extended server socket \n26\nint MainWindow_C_CODE_FORM::C_CODE_Scanner() @ line 238"
    

    I am looking for explanation / solution - preferably using QString

    D 1 Reply Last reply
    0
    • A Anonymous_Banned275

      Re: How to add newline to a QString?

      The attached C code FAILS to insert "\n" or "\t" when the main variable is QString. ( string concatenation)

             QString text = "VERIFY SUCCESS OK allocated extended server socket ";
                  text += "\n";
                  text += QString::number(server_socket);
                  text += "\n";
                  text += Q_FUNC_INFO;
                  text += " @ line ";
                  text += QString::number(__LINE__);
                  qDebug() << text;
      

      Here is the actual code output

      "int MainWindow_C_CODE_FORM::C_CODE_Scanner() @ line 211"
      "VERIFY SUCCESS OK allocated extended server socket \n26\nint MainWindow_C_CODE_FORM::C_CODE_Scanner() @ line 238"
      

      I am looking for explanation / solution - preferably using QString

      D Offline
      D Offline
      DerReisende
      wrote on last edited by
      #2

      @AnneRanch use qDebug().noquote() << text;

      Christian EhrlicherC 1 Reply Last reply
      0
      • D DerReisende

        @AnneRanch use qDebug().noquote() << text;

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Already answered three days ago here: https://forum.qt.io/topic/144069/

        And again: You must not use qDebug() for formatted output to the console as it is for debugging purposes. Closing this thread.

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

        1 Reply Last reply
        1
        • Christian EhrlicherC Christian Ehrlicher locked this topic on

        • Login

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