1

I adjust the QT_MESSAGE_PATTERN on build environment both for pc and raspberry.

When I did a run on pc, debug gives me an output as I adjusted but when a did a run on raspberry pi (deployment) , debug gives me an output like I didn't adjust....

here is adjustment;

QT_MESSAGE_PATTERN = "[(%{file}:%{line}) - %{message}"
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
bladekel
  • 37
  • 7

2 Answers2

1

in order to work you need to do:

  1. qSetMessagePattern(QT_MESSAGE_PATTERN);
  2. qInstallMessageHandler(yourCustomMessageHandler);
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
1

You need to set the message pattern; at the beginning of int main() add qputenv("QT_MESSAGE_PATTERN", QByteArray("[(%{file}:%{line}) - %{message}"));

Try this snippet:

#include <QDebug>

#include <unistd.h>

int main(int /*argc*/, char* /*argv*/ [])
{
    qputenv("QT_MESSAGE_PATTERN", QByteArray("[(%{file}:%{line}) - %{message}"));

    while (1) {
        sleep(1);
        qDebug() << "Message";
    }
}
Andrea Ricchi
  • 480
  • 5
  • 12
  • Excuse me for a late reply but I have tried your suggest. It works on pc side, but If I deploy to raspberry pi, I couldnt see what I have expected .... – bladekel Jan 18 '20 at 07:28
  • Please note that I'm trying to deploy the project to raspberry pi from pc and I wantted to see this pattern on pc while program running on raspberry (deployed)... – bladekel Jan 18 '20 at 07:33
  • I work daily on embedded systems, and this is the way to go! Are you deploying the application via QtCreator? – Andrea Ricchi Jan 19 '20 at 10:46
  • Yes, I'm working with QtCreator.... but I want to add sth, I have created the os with buildroot... Can be sth missing on OS ? – bladekel Jan 21 '20 at 06:51
  • I suggest trying this small snippet on the desktop. If it doesn't work you have to check some project/QtCreator option. If it works then move on the embedded system; I suggest cross-compile/deploy via QtCreator, then run the app from the debug serial o by connecting via SSH. – Andrea Ricchi Jan 21 '20 at 08:32