QT_MESSAGE_PATTERN not works over raspberry pi crosscompile

473 Views Asked by At

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}"
2

There are 2 best solutions below

2
ΦXocę 웃 Пepeúpa ツ On

in order to work you need to do:

  1. qSetMessagePattern(QT_MESSAGE_PATTERN);
  2. qInstallMessageHandler(yourCustomMessageHandler);
5
Andrea Ricchi On

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";
    }
}