Solved Console without " problem
-
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(); }
-
@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. -
using macro
qPrintable()
-
-
@RiceBall As @Devopia53 suggested do:
std::cout << qPrintable(mitm.fileName());
or
std::cout << mitm.fileName().toStdString();
-
Thank you for your help.
I do it. -
I know this is solved, but just as a follow up, you could try
qDebug.noquote() << command << mitm.fileName();