How to print string literal and QString with qDebug?
You can use the following: qDebug().nospace() << “abc” << qPrintable(s) << “def”; The nospace() is to avoid printing out spaces after every argument (which is default for qDebug()).
You can use the following: qDebug().nospace() << “abc” << qPrintable(s) << “def”; The nospace() is to avoid printing out spaces after every argument (which is default for qDebug()).
It would be best to understand how QDebug works internally. That way you can easily modify it to suit your needs. Whenever you use the qDebug() function, it returns a QDebug object. By default QDebug always outputs a space after any use of operator <<. The QDebug class internally contains a QString. Every time you … Read more
You’ve to install a message handler using qInstallMessageHandler function, and then, you can use QTextStream to write the debug message to a file. Here is a sample example: #include <QtGlobal> #include <stdio.h> #include <stdlib.h> void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { QByteArray localMsg = msg.toLocal8Bit(); switch (type) { case QtDebugMsg: fprintf(stderr, “Debug: … Read more