Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Embedded QT: How to Fix the Error "QWidget::paintEngine: Should no longer be called"
QtWS25 Last Chance

Embedded QT: How to Fix the Error "QWidget::paintEngine: Should no longer be called"

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 2 Posters 1.8k 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.
  • A Offline
    A Offline
    andy0914
    wrote on 21 Nov 2019, 06:08 last edited by
    #1

    Hi everyone,

    Now I am trying to make the embedded QT GUI run on the Ambarella CV25 board. I had cross-compiled the QT 5.12.3 everywhere and compiled a simple qt example. The cross compiler is Ambarella CV25 linaro-aarch64-2018.08-gcc8.2/bin/aarch64-linux-gnu-xxx.

    When I download the qt lib and example to the board, I encountered the following issue:

    ./my_second_example -platform linuxfb
    QIconvCodec::convertToUnicode: using Latin-1 for conversion, iconv_open failed
    QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv_open failed
    QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
    QWidget::paintEngine: Should no longer be called
    QPainter::begin: Paint device returned engine == 0, type: 1
    QPainter::setPen: Painter not active
    QPainter::setBrush: Painter not active
    QPainter::drawRects: Painter not active
    debug paintEvent(): QPaintDevice  0x7fe05f0d78
    debug paintEvent():  painter.isActive  false
    debug paintEvent(): QPaintEngine  0x0
    .....
    

    Could anyone know how to fix the issue? I searched the web, but all posts I found had either no answer to them, or give suggestion that paint under the paintEvent function.
    Thanks a million!

    My Code:

    • PaintTest.h:
    #ifndef PAINTTEST_H
    #define PAINTTEST_H
    
    #include <QWidget>
    #include <QLabel>
    #include <QPainter>
    class PaintTest : public QWidget
    {
        Q_OBJECT
    
    public:
         explicit PaintTest(QWidget *parent = nullptr);
         void paintEvent(QPaintEvent *);
    };
    #endif // PAINTTEST_H
    
    • PaintTest.cpp
    #include "PaintTest.h"
    #include <QLabel>
    #include <QEvent>
    #include <QDebug>
    
    PaintTest::PaintTest(QWidget *parent) :
        QWidget(parent)
    {
    
    }
    
    void PaintTest::paintEvent(QPaintEvent *) {
         QPainter painter(this);
    
         painter.begin(this);
         painter.setPen(Qt::gray);
         painter.setBrush(Qt::green);
         painter.drawRect(10, 20, 50, 50);
         //painter.drawText(rect(),Qt::AlignCenter,tr("Draganddropfile(s)here"));
    
         qDebug()<<"debug paintEvent(): QPaintDevice " << painter.device();
         qDebug()<<"debug paintEvent(): painter.isActive " << painter.isActive();
         qDebug()<<"debug paintEvent(): QPaintEngine " << painter.paintEngine();
         painter.end();
    }
    
    • main.cpp
    #include <QApplication>
    #include "PaintTest.h"
    
    int main(int argc,char* argv[])
    {
         QApplication a(argc, argv);
    
        PaintTest pt;
         pt.show();
    
         return a.exec();
    }
    

    And I will also provide the embedded qt configure parameters when I cross-compiled the qt everywhere:

    ../qt-everywhere-src-5.12.3/configure -v -prefix /home/andy/Amb/cv2x_linux_sdk_2.5/workspace/build_qt/output -release -opensource -confirm-license -no-accessibility -make libs -xplatform linux-aarch64-gnu-g++ -optimized-qmake -pch -qt-zlib -no-opengl -no-sse2 -no-openssl -no-cups -no-glib -no-pkg-config -no-separate-debug-info -tslib -I/home/andy/Amb/cv2x_linux_sdk_2.5/ambarella/prebuild/third-party/armv8-a/tslib/include -L/home/andy/Amb/cv2x_linux_sdk_2.5/ambarella/prebuild/third-party/armv8-a/tslib/usr/lib -skip qtdeclarative
    

    The CV25 platform not support opengl, so I disable the eglfs, use the linuxfb.

    Thanks again!!!
    andy

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 21 Nov 2019, 16:46 last edited by
      #2

      Hi and welcome to devnet,

      Since you pass your instance when creating the painter, there is no need to call begin. I'll start with that.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andy0914
        wrote on 22 Nov 2019, 06:47 last edited by
        #3

        @SGaist said in Embedded QT: How to Fix the Error "QWidget::paintEngine: Should no longer be called":

        Since you pass your instance when creating the painter, there is no need to call begin. I'll start with that.

        Thanks for your reply! yes, there is no need to call begin and end. It is the same result when not call begin.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 22 Nov 2019, 22:41 last edited by SGaist
          #4

          What device are you running that on ?
          Does showing a simple widget work correctly ?

          [edit: fixed missing word SGaist]

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          A 1 Reply Last reply 27 Nov 2019, 05:22
          0
          • S SGaist
            22 Nov 2019, 22:41

            What device are you running that on ?
            Does showing a simple widget work correctly ?

            [edit: fixed missing word SGaist]

            A Offline
            A Offline
            andy0914
            wrote on 27 Nov 2019, 05:22 last edited by
            #5

            @SGaist Hi, the device is the ambarella CV25 chip Develop Board. It run an embedded linux kernel, the frame buffer device in linux kernel also work well. There were no samples in its SDK. I just tried to run this simple sample but failed.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 27 Nov 2019, 21:27 last edited by
              #6

              Sorry, I just saw there was a missing word in my phrase and fixed it.

              What do you get if you just show a normal unmodified QWidget object ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              6/6

              27 Nov 2019, 21:27

              • Login

              • Login or register to search.
              6 out of 6
              • First post
                6/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved