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. How to use QDebug in QT console
Qt 6.11 is out! See what's new in the release blog

How to use QDebug in QT console

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 44.6k 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.
  • V Offline
    V Offline
    victor wang
    wrote on last edited by
    #1

    Hi All,
    I'm using qt5.5 on my computer and Linux+QT for my OS system.
    I'm using qtcreator to creat a new project with QT Console.
    And this is my program.

    #include <QCoreApplication>
    #include <QDebug>
    #include <QtSerialPort/QSerialPort>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        bool ignition_bios_name_error=false;
        QSerialPort comport;
        QString comportstring="/dev/ttymxc2";
        comport.setPortName(comportstring);
        comport.setBaudRate(QSerialPort::Baud9600);
        comport.setDataBits(QSerialPort::Data8);
        comport.setParity(QSerialPort::NoParity);
        comport.setStopBits(QSerialPort::OneStop);
    
        const char BIOS_COM[4]={0x04,0xA0,0x00,0x5C};
        const char BIOS_name[4]={0x04,0xA0,0x01,0x5B};
    
        if (!comport.open(QIODevice::ReadWrite)) {
            qDebug("cannot open");//<<comport.errorString();
        }
        qint64 bytesWritten = comport.write(BIOS_COM,sizeof(BIOS_COM));
    
        if (bytesWritten == -1)
        {
            qDebug("Failed to write the data to port");
        }
        else if (!comport.waitForBytesWritten(80))
        {
            qDebug("Operation timed out or an error occurred for port");
        }
        QByteArray readData=comport.readAll();
        while(comport.waitForReadyRead(80))
            readData.append(comport.readAll());
        if (comport.error() == QSerialPort::ReadError)
        {
            QDebug("read error");
            ignition_bios_name_error = true;
        }
        else if (comport.error() == QSerialPort::TimeoutError && readData.isEmpty())
        {
            QDebug("timed out");
            ignition_bios_name_error = true;
        }
        if(readData.contains("93FA1000WN0A"))
        {
            qDebug()<<"NAME: "+readData.constData();
        }
        else
        {
            qDebug("wrong data");
            ignition_bios_name_error = true;
        }
        bytesWritten = comport.write(BIOS_name,sizeof(BIOS_name));
    
        if (bytesWritten == -1)
        {
            qDebug("Failed to write the data to port");
        }
        else if (!comport.waitForBytesWritten(80))
        {
            qDebug("Operation timed out or an error occurred for port");
        }
        readData=comport.readAll();
        while(comport.waitForReadyRead(80))
            readData.append(comport.readAll());
        if (comport.error() == QSerialPort::ReadError)
        {
           QDebug("BIOS read error");
        }
        else if (comport.error() == QSerialPort::TimeoutError && readData.isEmpty())
        {
            QDebug("BIOS timed out");
        }
        else if(readData.contains("FA3A110-000000000-000-VV120-WN"))
        {
            if(!ignition_bios_name_error)
            {
                qDebug()<<"BIOS_version: "+readData.constData()+"  And BIOS_name error";
            }
            else
            {
                qDebug()<<"BIOS_version: "+readData.constData();
            }
        }
    
        return a.exec();
    }
    

    When I compile with qmake then it will give me the error.

    arm-poky-linux-gnueabi-g++  -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/mnt/raid115/victor/freescale/opt/fsl-imx-wayland/4.1.15/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi -c -pipe  -O2 -pipe -g -feliminate-unused-debug-types -O2 -DLINUX=1 -DEGL_API_FB=1 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_SERIALPORT_LIB -DQT_CORE_LIB -I. -I../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5 -I../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtSerialPort -I../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore -I. -I../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/linux-oe-g++ -o main.o main.cpp
    main.cpp: In function 'int main(int, char**)':
    main.cpp:41:28: error: no matching function for call to 'QDebug::QDebug(const char [11])'
             QDebug("read error");
                                ^
    In file included from ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/QDebug:1:0,
                     from main.cpp:2:
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note: candidate: QDebug::QDebug(const QDebug&)
         inline QDebug(const QDebug &o):stream(o.stream) { ++stream->ref; }
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note:   no known conversion for argument 1 from 'const char [11]' to 'const QDebug&'
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note: candidate: QDebug::QDebug(QtMsgType)
         inline QDebug(QtMsgType t) : stream(new Stream(t)) {}
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note:   no known conversion for argument 1 from 'const char [11]' to 'QtMsgType'
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note: candidate: QDebug::QDebug(QString*)
         inline QDebug(QString *string) : stream(new Stream(string)) {}
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note:   no known conversion for argument 1 from 'const char [11]' to 'QString*'
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note: candidate: QDebug::QDebug(QIODevice*)
         inline QDebug(QIODevice *device) : stream(new Stream(device)) {}
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note:   no known conversion for argument 1 from 'const char [11]' to 'QIODevice*'
    main.cpp:46:27: error: no matching function for call to 'QDebug::QDebug(const char [10])'
             QDebug("timed out");
                               ^
    In file included from ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/QDebug:1:0,
                     from main.cpp:2:
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note: candidate: QDebug::QDebug(const QDebug&)
         inline QDebug(const QDebug &o):stream(o.stream) { ++stream->ref; }
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note:   no known conversion for argument 1 from 'const char [10]' to 'const QDebug&'
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note: candidate: QDebug::QDebug(QtMsgType)
         inline QDebug(QtMsgType t) : stream(new Stream(t)) {}
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note:   no known conversion for argument 1 from 'const char [10]' to 'QtMsgType'
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note: candidate: QDebug::QDebug(QString*)
         inline QDebug(QString *string) : stream(new Stream(string)) {}
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note:   no known conversion for argument 1 from 'const char [10]' to 'QString*'
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note: candidate: QDebug::QDebug(QIODevice*)
         inline QDebug(QIODevice *device) : stream(new Stream(device)) {}
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note:   no known conversion for argument 1 from 'const char [10]' to 'QIODevice*'
    main.cpp:51:47: error: invalid operands of types 'const char [7]' and 'const char*' to binary 'operator+'
             qDebug()<<"NAME: "+readData.constData();
                                                   ^
    main.cpp:73:32: error: no matching function for call to 'QDebug::QDebug(const char [16])'
            QDebug("BIOS read error");
                                    ^
    In file included from ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/QDebug:1:0,
                     from main.cpp:2:
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note: candidate: QDebug::QDebug(const QDebug&)
         inline QDebug(const QDebug &o):stream(o.stream) { ++stream->ref; }
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note:   no known conversion for argument 1 from 'const char [16]' to 'const QDebug&'
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note: candidate: QDebug::QDebug(QtMsgType)
         inline QDebug(QtMsgType t) : stream(new Stream(t)) {}
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note:   no known conversion for argument 1 from 'const char [16]' to 'QtMsgType'
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note: candidate: QDebug::QDebug(QString*)
         inline QDebug(QString *string) : stream(new Stream(string)) {}
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note:   no known conversion for argument 1 from 'const char [16]' to 'QString*'
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note: candidate: QDebug::QDebug(QIODevice*)
         inline QDebug(QIODevice *device) : stream(new Stream(device)) {}
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note:   no known conversion for argument 1 from 'const char [16]' to 'QIODevice*'
    main.cpp:77:32: error: no matching function for call to 'QDebug::QDebug(const char [15])'
             QDebug("BIOS timed out");
                                    ^
    In file included from ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/QDebug:1:0,
                     from main.cpp:2:
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note: candidate: QDebug::QDebug(const QDebug&)
         inline QDebug(const QDebug &o):stream(o.stream) { ++stream->ref; }
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note:   no known conversion for argument 1 from 'const char [15]' to 'const QDebug&'
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note: candidate: QDebug::QDebug(QtMsgType)
         inline QDebug(QtMsgType t) : stream(new Stream(t)) {}
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note:   no known conversion for argument 1 from 'const char [15]' to 'QtMsgType'
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note: candidate: QDebug::QDebug(QString*)
         inline QDebug(QString *string) : stream(new Stream(string)) {}
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note:   no known conversion for argument 1 from 'const char [15]' to 'QString*'
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note: candidate: QDebug::QDebug(QIODevice*)
         inline QDebug(QIODevice *device) : stream(new Stream(device)) {}
                ^
    ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note:   no known conversion for argument 1 from 'const char [15]' to 'QIODevice*'
    main.cpp:83:59: error: invalid operands of types 'const char [15]' and 'const char*' to binary 'operator+'
                 qDebug()<<"BIOS_version: "+readData.constData()+"  And BIOS_name error";
                                                               ^
    main.cpp:87:59: error: invalid operands of types 'const char [15]' and 'const char*' to binary 'operator+'
                 qDebug()<<"BIOS_version: "+readData.constData();
                                                               ^
    make: *** [main.o] Error 1
    

    How to fix this problem?

    Thanks in Advanced!

    joeQJ 1 Reply Last reply
    0
    • V victor wang

      Hi All,
      I'm using qt5.5 on my computer and Linux+QT for my OS system.
      I'm using qtcreator to creat a new project with QT Console.
      And this is my program.

      #include <QCoreApplication>
      #include <QDebug>
      #include <QtSerialPort/QSerialPort>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          bool ignition_bios_name_error=false;
          QSerialPort comport;
          QString comportstring="/dev/ttymxc2";
          comport.setPortName(comportstring);
          comport.setBaudRate(QSerialPort::Baud9600);
          comport.setDataBits(QSerialPort::Data8);
          comport.setParity(QSerialPort::NoParity);
          comport.setStopBits(QSerialPort::OneStop);
      
          const char BIOS_COM[4]={0x04,0xA0,0x00,0x5C};
          const char BIOS_name[4]={0x04,0xA0,0x01,0x5B};
      
          if (!comport.open(QIODevice::ReadWrite)) {
              qDebug("cannot open");//<<comport.errorString();
          }
          qint64 bytesWritten = comport.write(BIOS_COM,sizeof(BIOS_COM));
      
          if (bytesWritten == -1)
          {
              qDebug("Failed to write the data to port");
          }
          else if (!comport.waitForBytesWritten(80))
          {
              qDebug("Operation timed out or an error occurred for port");
          }
          QByteArray readData=comport.readAll();
          while(comport.waitForReadyRead(80))
              readData.append(comport.readAll());
          if (comport.error() == QSerialPort::ReadError)
          {
              QDebug("read error");
              ignition_bios_name_error = true;
          }
          else if (comport.error() == QSerialPort::TimeoutError && readData.isEmpty())
          {
              QDebug("timed out");
              ignition_bios_name_error = true;
          }
          if(readData.contains("93FA1000WN0A"))
          {
              qDebug()<<"NAME: "+readData.constData();
          }
          else
          {
              qDebug("wrong data");
              ignition_bios_name_error = true;
          }
          bytesWritten = comport.write(BIOS_name,sizeof(BIOS_name));
      
          if (bytesWritten == -1)
          {
              qDebug("Failed to write the data to port");
          }
          else if (!comport.waitForBytesWritten(80))
          {
              qDebug("Operation timed out or an error occurred for port");
          }
          readData=comport.readAll();
          while(comport.waitForReadyRead(80))
              readData.append(comport.readAll());
          if (comport.error() == QSerialPort::ReadError)
          {
             QDebug("BIOS read error");
          }
          else if (comport.error() == QSerialPort::TimeoutError && readData.isEmpty())
          {
              QDebug("BIOS timed out");
          }
          else if(readData.contains("FA3A110-000000000-000-VV120-WN"))
          {
              if(!ignition_bios_name_error)
              {
                  qDebug()<<"BIOS_version: "+readData.constData()+"  And BIOS_name error";
              }
              else
              {
                  qDebug()<<"BIOS_version: "+readData.constData();
              }
          }
      
          return a.exec();
      }
      

      When I compile with qmake then it will give me the error.

      arm-poky-linux-gnueabi-g++  -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/mnt/raid115/victor/freescale/opt/fsl-imx-wayland/4.1.15/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi -c -pipe  -O2 -pipe -g -feliminate-unused-debug-types -O2 -DLINUX=1 -DEGL_API_FB=1 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_SERIALPORT_LIB -DQT_CORE_LIB -I. -I../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5 -I../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtSerialPort -I../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore -I. -I../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/linux-oe-g++ -o main.o main.cpp
      main.cpp: In function 'int main(int, char**)':
      main.cpp:41:28: error: no matching function for call to 'QDebug::QDebug(const char [11])'
               QDebug("read error");
                                  ^
      In file included from ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/QDebug:1:0,
                       from main.cpp:2:
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note: candidate: QDebug::QDebug(const QDebug&)
           inline QDebug(const QDebug &o):stream(o.stream) { ++stream->ref; }
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note:   no known conversion for argument 1 from 'const char [11]' to 'const QDebug&'
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note: candidate: QDebug::QDebug(QtMsgType)
           inline QDebug(QtMsgType t) : stream(new Stream(t)) {}
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note:   no known conversion for argument 1 from 'const char [11]' to 'QtMsgType'
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note: candidate: QDebug::QDebug(QString*)
           inline QDebug(QString *string) : stream(new Stream(string)) {}
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note:   no known conversion for argument 1 from 'const char [11]' to 'QString*'
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note: candidate: QDebug::QDebug(QIODevice*)
           inline QDebug(QIODevice *device) : stream(new Stream(device)) {}
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note:   no known conversion for argument 1 from 'const char [11]' to 'QIODevice*'
      main.cpp:46:27: error: no matching function for call to 'QDebug::QDebug(const char [10])'
               QDebug("timed out");
                                 ^
      In file included from ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/QDebug:1:0,
                       from main.cpp:2:
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note: candidate: QDebug::QDebug(const QDebug&)
           inline QDebug(const QDebug &o):stream(o.stream) { ++stream->ref; }
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note:   no known conversion for argument 1 from 'const char [10]' to 'const QDebug&'
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note: candidate: QDebug::QDebug(QtMsgType)
           inline QDebug(QtMsgType t) : stream(new Stream(t)) {}
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note:   no known conversion for argument 1 from 'const char [10]' to 'QtMsgType'
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note: candidate: QDebug::QDebug(QString*)
           inline QDebug(QString *string) : stream(new Stream(string)) {}
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note:   no known conversion for argument 1 from 'const char [10]' to 'QString*'
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note: candidate: QDebug::QDebug(QIODevice*)
           inline QDebug(QIODevice *device) : stream(new Stream(device)) {}
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note:   no known conversion for argument 1 from 'const char [10]' to 'QIODevice*'
      main.cpp:51:47: error: invalid operands of types 'const char [7]' and 'const char*' to binary 'operator+'
               qDebug()<<"NAME: "+readData.constData();
                                                     ^
      main.cpp:73:32: error: no matching function for call to 'QDebug::QDebug(const char [16])'
              QDebug("BIOS read error");
                                      ^
      In file included from ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/QDebug:1:0,
                       from main.cpp:2:
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note: candidate: QDebug::QDebug(const QDebug&)
           inline QDebug(const QDebug &o):stream(o.stream) { ++stream->ref; }
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note:   no known conversion for argument 1 from 'const char [16]' to 'const QDebug&'
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note: candidate: QDebug::QDebug(QtMsgType)
           inline QDebug(QtMsgType t) : stream(new Stream(t)) {}
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note:   no known conversion for argument 1 from 'const char [16]' to 'QtMsgType'
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note: candidate: QDebug::QDebug(QString*)
           inline QDebug(QString *string) : stream(new Stream(string)) {}
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note:   no known conversion for argument 1 from 'const char [16]' to 'QString*'
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note: candidate: QDebug::QDebug(QIODevice*)
           inline QDebug(QIODevice *device) : stream(new Stream(device)) {}
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note:   no known conversion for argument 1 from 'const char [16]' to 'QIODevice*'
      main.cpp:77:32: error: no matching function for call to 'QDebug::QDebug(const char [15])'
               QDebug("BIOS timed out");
                                      ^
      In file included from ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/QDebug:1:0,
                       from main.cpp:2:
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note: candidate: QDebug::QDebug(const QDebug&)
           inline QDebug(const QDebug &o):stream(o.stream) { ++stream->ref; }
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:89:12: note:   no known conversion for argument 1 from 'const char [15]' to 'const QDebug&'
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note: candidate: QDebug::QDebug(QtMsgType)
           inline QDebug(QtMsgType t) : stream(new Stream(t)) {}
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:88:12: note:   no known conversion for argument 1 from 'const char [15]' to 'QtMsgType'
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note: candidate: QDebug::QDebug(QString*)
           inline QDebug(QString *string) : stream(new Stream(string)) {}
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:87:12: note:   no known conversion for argument 1 from 'const char [15]' to 'QString*'
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note: candidate: QDebug::QDebug(QIODevice*)
           inline QDebug(QIODevice *device) : stream(new Stream(device)) {}
                  ^
      ../../../sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/usr/include/qt5/QtCore/qdebug.h:86:12: note:   no known conversion for argument 1 from 'const char [15]' to 'QIODevice*'
      main.cpp:83:59: error: invalid operands of types 'const char [15]' and 'const char*' to binary 'operator+'
                   qDebug()<<"BIOS_version: "+readData.constData()+"  And BIOS_name error";
                                                                 ^
      main.cpp:87:59: error: invalid operands of types 'const char [15]' and 'const char*' to binary 'operator+'
                   qDebug()<<"BIOS_version: "+readData.constData();
                                                                 ^
      make: *** [main.o] Error 1
      

      How to fix this problem?

      Thanks in Advanced!

      joeQJ Offline
      joeQJ Offline
      joeQ
      wrote on last edited by
      #2

      @victor-wang hi,friend,welcome.

      You write qDebug() to QDebug(), Note qDebug

      if (comport.error() == QSerialPort::ReadError)
          {
              QDebug("read error"); ///< use qDebug("......");
              ignition_bios_name_error = true;
          }
          else if (comport.error() == QSerialPort::TimeoutError && readData.isEmpty())
          {
              QDebug("timed out"); ///< use qDebug("......");
              ignition_bios_name_error = true;
          }
      

      Just do it!

      jsulmJ 1 Reply Last reply
      1
      • joeQJ joeQ

        @victor-wang hi,friend,welcome.

        You write qDebug() to QDebug(), Note qDebug

        if (comport.error() == QSerialPort::ReadError)
            {
                QDebug("read error"); ///< use qDebug("......");
                ignition_bios_name_error = true;
            }
            else if (comport.error() == QSerialPort::TimeoutError && readData.isEmpty())
            {
                QDebug("timed out"); ///< use qDebug("......");
                ignition_bios_name_error = true;
            }
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @joeQ @victor-wang Actually it should be:

        if (comport.error() == QSerialPort::ReadError)
        {
            qDebug() << "read error"; ///< use qDebug("......");
            ignition_bios_name_error = true;
        }
        else if (comport.error() == QSerialPort::TimeoutError && readData.isEmpty())
        {
            qDebug() << "timed out"; ///< use qDebug("......");
            ignition_bios_name_error = true;
         }
        

        It is explained in the documentation even with examples: http://doc.qt.io/qt-5/qdebug.html

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

        joeQJ 1 Reply Last reply
        1
        • jsulmJ jsulm

          @joeQ @victor-wang Actually it should be:

          if (comport.error() == QSerialPort::ReadError)
          {
              qDebug() << "read error"; ///< use qDebug("......");
              ignition_bios_name_error = true;
          }
          else if (comport.error() == QSerialPort::TimeoutError && readData.isEmpty())
          {
              qDebug() << "timed out"; ///< use qDebug("......");
              ignition_bios_name_error = true;
           }
          

          It is explained in the documentation even with examples: http://doc.qt.io/qt-5/qdebug.html

          joeQJ Offline
          joeQJ Offline
          joeQ
          wrote on last edited by joeQ
          #4

          @jsulm

          Thank you.

          is it also OK ?

          some one used to use C printf format, so, he like below format

          ///< int num. char* pstr
          qDebug("%d %s",num,pstr); ///< it also can run.
          
          // or
          str = QString("xxxxxx");
          qDebug("%s",qPrintable(str));
          

          does it must be qDebug() << XXX ?

          maybe qDebug() << XXX is strict.

          oh, I find the Qt Reference

          If you pass the function a format string and a list of arguments, it works in similar way to the C printf() function. The format should be a Latin-1 string.
          Example:

          qDebug("Items in list: %d", myList.size());

          Just do it!

          V 1 Reply Last reply
          0
          • joeQJ joeQ

            @jsulm

            Thank you.

            is it also OK ?

            some one used to use C printf format, so, he like below format

            ///< int num. char* pstr
            qDebug("%d %s",num,pstr); ///< it also can run.
            
            // or
            str = QString("xxxxxx");
            qDebug("%s",qPrintable(str));
            

            does it must be qDebug() << XXX ?

            maybe qDebug() << XXX is strict.

            oh, I find the Qt Reference

            If you pass the function a format string and a list of arguments, it works in similar way to the C printf() function. The format should be a Latin-1 string.
            Example:

            qDebug("Items in list: %d", myList.size());

            V Offline
            V Offline
            victor wang
            wrote on last edited by
            #5

            @joeQ
            @jsulm
            Thank you so much for helping me.
            I have to apologize that i make a such stupid mistake.
            I do not see that I type qDebug -> QDebug.

            And I've try both two command as following, It all works perfectly.

            qDebug("text");
            qDebug()<<"test";
            

            Also I've try modify my wrong program from

            qDebug()<<"BIOS_version: "+readData.constData()+"  And BIOS_name error";
            

            to

            qDebug()<<"BIOS_version: ";
            qDebug("%s",readData.constData());
            qDebug()<<"  And BIOS_name error";
            

            And It works also perfectly!

            Again thanks for helping me!

            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