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. Console without " problem
Forum Updated to NodeBB v4.3 + New Features

Console without " problem

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 728 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.
  • R Offline
    R Offline
    RiceBall
    wrote on last edited by
    #1

    I want to output some string.
    But those string are at stringlist.
    When I output them.
    It will be shown with ("")
    How could I fix it ??

    #include <QCoreApplication>
    #include <QDebug>           //在文字視窗輸出文字功能函式
    #include <QDir>             //搜尋資料夾功能函式
    #include <QFileInfo>        //顯示檔案資訊
    #include <QString>          //字串函式
    #include <QStringList>      //字串陣列函式
    
    
    main.cpp
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
           QDir mDir;    //設定資料夾位置
           qDebug() << mDir.exists();       //輸出確定是否有mDir資料夾
    
           QString command = "frtomem -p WnaYooAQ ";
    
            foreach(QFileInfo mitm, mDir.entryInfoList(Qfilter))     //列出所有資料夾中篩選的檔案內容
           {
               qDebug() << command << mitm.fileName();
           }
    
        return a.exec();
    }
    
    

    0_1557457657663_0e4634e4-e762-4de9-a5bc-5efea5c7d978-image.png

    jsulmJ 1 Reply Last reply
    0
    • R RiceBall

      I want to output some string.
      But those string are at stringlist.
      When I output them.
      It will be shown with ("")
      How could I fix it ??

      #include <QCoreApplication>
      #include <QDebug>           //在文字視窗輸出文字功能函式
      #include <QDir>             //搜尋資料夾功能函式
      #include <QFileInfo>        //顯示檔案資訊
      #include <QString>          //字串函式
      #include <QStringList>      //字串陣列函式
      
      
      main.cpp
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
             QDir mDir;    //設定資料夾位置
             qDebug() << mDir.exists();       //輸出確定是否有mDir資料夾
      
             QString command = "frtomem -p WnaYooAQ ";
      
              foreach(QFileInfo mitm, mDir.entryInfoList(Qfilter))     //列出所有資料夾中篩選的檔案內容
             {
                 qDebug() << command << mitm.fileName();
             }
      
          return a.exec();
      }
      
      

      0_1557457657663_0e4634e4-e762-4de9-a5bc-5efea5c7d978-image.png

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @RiceBall Don't use qDebug for normal output. qDebug is meant to be used for debug purposes and it puts strings in "" (and some other stuff).
      Use std::cout instead - this is the standard way in C++ to print to the console.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply
      4
      • D Offline
        D Offline
        Devopia53
        wrote on last edited by
        #3

        using macro qPrintable()

        1 Reply Last reply
        0
        • jsulmJ jsulm

          @RiceBall Don't use qDebug for normal output. qDebug is meant to be used for debug purposes and it puts strings in "" (and some other stuff).
          Use std::cout instead - this is the standard way in C++ to print to the console.

          R Offline
          R Offline
          RiceBall
          wrote on last edited by
          #4

          @jsulm said in Console without " problem:

          std::cout instead

          0_1557465520698_8adcd0a2-c7be-4993-99b9-44b8fe2dcb88-image.png

          What does it happend ??

          jsulmJ 1 Reply Last reply
          0
          • R RiceBall

            @jsulm said in Console without " problem:

            std::cout instead

            0_1557465520698_8adcd0a2-c7be-4993-99b9-44b8fe2dcb88-image.png

            What does it happend ??

            jsulmJ Online
            jsulmJ Online
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @RiceBall As @Devopia53 suggested do:

            std::cout << qPrintable(mitm.fileName());
            

            or

            std::cout << mitm.fileName().toStdString();
            

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            R 1 Reply Last reply
            3
            • jsulmJ jsulm

              @RiceBall As @Devopia53 suggested do:

              std::cout << qPrintable(mitm.fileName());
              

              or

              std::cout << mitm.fileName().toStdString();
              
              R Offline
              R Offline
              RiceBall
              wrote on last edited by
              #6

              @jsulm

              Thank you for your help.
              I do it.

              0_1557467415796_bb7f5908-1894-4101-9119-be581e952b32-image.png

              1 Reply Last reply
              0
              • mranger90M Offline
                mranger90M Offline
                mranger90
                wrote on last edited by
                #7

                I know this is solved, but just as a follow up, you could try

                qDebug.noquote() << command << mitm.fileName();
                
                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