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. Concatenating QString "\n" missess " new line
Forum Updated to NodeBB v4.3 + New Features

Concatenating QString "\n" missess " new line

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 914 Views 2 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

    Here is my code :

      #ifdef C_CODE_TRACE
                text = "   \n";
                text += "SUCCESS  dev_id = hci_get_route    ";
                text += QString::number(QET.elapsed());
                text += " mS";
                ui->textEdit->append(text);
                text += Q_FUNC_INFO;
                text += " @ line ";
                text += QString::number(__LINE__);
                text += "\t\n VERIFY dev_id = hci_get_route ";
                text += QString::number( dev_id );
                text += "\n";
                qDebug() << text;
       #endif
    
    ```Here is my debug output :
    
    
    "   /n   \nSUCCESS  dev_id = hci_get_route    0 mSint MainWindow_C_CODE_FORM::C_CODE_Scanner() @ line 289\t\n VERIFY dev_id = hci_get_route 0\n"
    
    
    What am I doing wrong since  I do not get  "new line \n " or  "tab \t" as expected?
    
    text is defined as 
    QString text;
    Christian EhrlicherC M 2 Replies Last reply
    0
    • A Anonymous_Banned275

      Here is my code :

        #ifdef C_CODE_TRACE
                  text = "   \n";
                  text += "SUCCESS  dev_id = hci_get_route    ";
                  text += QString::number(QET.elapsed());
                  text += " mS";
                  ui->textEdit->append(text);
                  text += Q_FUNC_INFO;
                  text += " @ line ";
                  text += QString::number(__LINE__);
                  text += "\t\n VERIFY dev_id = hci_get_route ";
                  text += QString::number( dev_id );
                  text += "\n";
                  qDebug() << text;
         #endif
      
      ```Here is my debug output :
      
      
      "   /n   \nSUCCESS  dev_id = hci_get_route    0 mSint MainWindow_C_CODE_FORM::C_CODE_Scanner() @ line 289\t\n VERIFY dev_id = hci_get_route 0\n"
      
      
      What am I doing wrong since  I do not get  "new line \n " or  "tab \t" as expected?
      
      text is defined as 
      QString text;
      Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      @AnneRanch said in Concatenating QString "\n" missess " new line:

      What am I doing wrong since I do not get "new line \n " or "tab \t" as expected?

      But your debug output shows the newline and tab exactly as you added them before.

      e.g. '289\t\n VERIFY' - a tab and a newline as debug output.

      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
      0
      • Christian EhrlicherC Christian Ehrlicher moved this topic from C++ Gurus on
      • A Anonymous_Banned275

        Here is my code :

          #ifdef C_CODE_TRACE
                    text = "   \n";
                    text += "SUCCESS  dev_id = hci_get_route    ";
                    text += QString::number(QET.elapsed());
                    text += " mS";
                    ui->textEdit->append(text);
                    text += Q_FUNC_INFO;
                    text += " @ line ";
                    text += QString::number(__LINE__);
                    text += "\t\n VERIFY dev_id = hci_get_route ";
                    text += QString::number( dev_id );
                    text += "\n";
                    qDebug() << text;
           #endif
        
        ```Here is my debug output :
        
        
        "   /n   \nSUCCESS  dev_id = hci_get_route    0 mSint MainWindow_C_CODE_FORM::C_CODE_Scanner() @ line 289\t\n VERIFY dev_id = hci_get_route 0\n"
        
        
        What am I doing wrong since  I do not get  "new line \n " or  "tab \t" as expected?
        
        text is defined as 
        QString text;
        M Offline
        M Offline
        mpergand
        wrote on last edited by
        #3

        @AnneRanch said in Concatenating QString "\n" missess " new line:
        qDebug() << qPrintable(text);

        A 1 Reply Last reply
        0
        • M mpergand

          @AnneRanch said in Concatenating QString "\n" missess " new line:
          qDebug() << qPrintable(text);

          A Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by
          #4

          @mpergand Sorry, not a full solution .

          
          "   \nSUCCESS  dev_id = hci_get_route    \n0\n  mS \nint MainWindow_C_CODE_FORM::C_CODE_Scanner() @ line 289\t\n VERIFY dev_id = hci_get_route 0\n"
             
          SUCCESS  dev_id = hci_get_route    
          0
            mS 
          int MainWindow_C_CODE_FORM::C_CODE_Scanner() @ line 289	
           VERIFY dev_id = hci_get_route 0            NO TAB HERE 
          
          
          

          It only works when "new line" IS the only code in " text += "....

          #ifdef C_CODE_TRACE
          
                    text = "   \n";
                    text += "SUCCESS  dev_id = hci_get_route    \n";
                    text += QString::number(QET.elapsed());
                    text += "\n  mS \n";
                    //text += &(ii+i)->bdaddr.toString();
                    //text += name; //
                    ui->textEdit->append(text);
                    text += Q_FUNC_INFO;
                    text += " @ line ";
                    text += QString::number(__LINE__);
                    text += "\t\n VERIFY dev_id = hci_get_route ";
                    text += QString::number( dev_id );
                    text += "\n";
                    qDebug() << text;
          
                    qDebug() << qPrintable(text);
           #endif
          

          '

          Christian EhrlicherC 1 Reply Last reply
          0
          • A Anonymous_Banned275

            @mpergand Sorry, not a full solution .

            
            "   \nSUCCESS  dev_id = hci_get_route    \n0\n  mS \nint MainWindow_C_CODE_FORM::C_CODE_Scanner() @ line 289\t\n VERIFY dev_id = hci_get_route 0\n"
               
            SUCCESS  dev_id = hci_get_route    
            0
              mS 
            int MainWindow_C_CODE_FORM::C_CODE_Scanner() @ line 289	
             VERIFY dev_id = hci_get_route 0            NO TAB HERE 
            
            
            

            It only works when "new line" IS the only code in " text += "....

            #ifdef C_CODE_TRACE
            
                      text = "   \n";
                      text += "SUCCESS  dev_id = hci_get_route    \n";
                      text += QString::number(QET.elapsed());
                      text += "\n  mS \n";
                      //text += &(ii+i)->bdaddr.toString();
                      //text += name; //
                      ui->textEdit->append(text);
                      text += Q_FUNC_INFO;
                      text += " @ line ";
                      text += QString::number(__LINE__);
                      text += "\t\n VERIFY dev_id = hci_get_route ";
                      text += QString::number( dev_id );
                      text += "\n";
                      qDebug() << text;
            
                      qDebug() << qPrintable(text);
             #endif
            

            '

            Christian EhrlicherC Online
            Christian EhrlicherC Online
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by Christian Ehrlicher
            #5

            You must not use qDebug() when you want to output something to the console not indented for debug output...

            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 referenced 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