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. QWidget::paintEngine: Should no longer be called
Forum Update on Monday, May 27th 2025

QWidget::paintEngine: Should no longer be called

Scheduled Pinned Locked Moved Unsolved General and Desktop
qwidgetpaintengine
7 Posts 2 Posters 4.2k 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.
  • PsnarfP Offline
    PsnarfP Offline
    Psnarf
    wrote on last edited by Psnarf
    #1

    Re: QWidget::paintEngine: Should no longer be called

    Qt/Examples/Qt-5.13.0/multimediawidgets/player

    The message presents itself in the Application Output window, a couple of times upon opening a MP4 video, then more upon selecting FullScreen. There is no explicit call to QWidget::paintEngine in player source code, but the Headers bring in qpaintengine.h and its override in qwidget.h:
    585 QPaintEngine *paintEngine() const override;
    The current docs mention nothing about why QWidget::paintEngine should no longer be called.

    Was QWidget::paintEngine deprecated?
    30Jul2019

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      No, it's not deprecated. The deprecation notice appears at build time.

      This message says that the painter has been called somehow at the wrong time.

      What OS are you on ?

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

      PsnarfP 1 Reply Last reply
      0
      • PsnarfP Offline
        PsnarfP Offline
        Psnarf
        wrote on last edited by
        #3

        I'm running Linux. I used the maintenance tool to install Qt 5.13.0. I was teaching myself how to use the UI Design Tool to create the Player interface, signals/slots. Built and ran the published Example player to make sure I had all of the correct buttons and icons, when I noticed all of the paintEngine messages.

        KDE Plasma v5.16.3, kernel 4.19.62, amdgpu with mesa 19.1.3, AMD ryzen5 2500U, Radeon Vega Mobile Gfx, llvm 8,0,1.

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          No, it's not deprecated. The deprecation notice appears at build time.

          This message says that the painter has been called somehow at the wrong time.

          What OS are you on ?

          PsnarfP Offline
          PsnarfP Offline
          Psnarf
          wrote on last edited by
          #4

          @sgaist

          When I put my QPainter in the main widget with the widget.ui, I got a blank widget with the following messages in the Application Output:

          QWidget::paintEngine: Should no longer be called
          QPainter::begin: Paint device returned engine == 0, type: 1
          QPainter::setPen: Painter not active
          

          I created a sub-widget class

          QWidget::paintEvent(QPaintEvent *event)
          

          moved all my drawing (QPainter::drawLines, QPen::setColor, QPointF, QLineF, QVector<QLineF>) into that class., leaving the main widget with only setupUI.

          No more messages, the ui widget now contains correctly rendered polygons.
          Perhaps we need to update some of the Examples?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Can you show the exact change you did ?

            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
            • PsnarfP Offline
              PsnarfP Offline
              Psnarf
              wrote on last edited by
              #6

              I'm teaching myself how to draw lines. I gave up on the player example after I switched from full-screen esc back to normal and the player window detached, playing in a small box in the upper left corner of the screen while the player window had static wide black and white lines in it.
              This is what generated the above. No doubt better ways to do it, but it's a start.

              Widget::Widget(QWidget *parent) :
                  QWidget(parent),
                  ui(new Ui::Widget)
              {
                  ui->setupUi(this);
              }
              
              Widget::~Widget()
              {
                  delete ui;
              }
              
              void Widget::paintEvent(QPaintEvent *e)
              {
                  // Base triangle
                  qreal myWidthF  = this->width();
                  qreal myHeightF = this->height();
              
                  QPointF pt1, pt2, pt3;
                  pt1.setX(0 + 1);
                  pt1.setY(myHeightF - 1);
                  pt2.setX(myWidthF/2 + 1);
                  pt2.setY(0 + 1);
                  pt3.setX(myWidthF - 1);
                  pt3.setY(myHeightF - 1);
              
                  QLineF side1, side2, side3;
                  side1 = QLineF(pt1, pt2);
                  side2 = QLineF(pt2, pt3);
                  side3 = QLineF(pt3, pt1);
              
                  QVector<QLineF> myTriangle;
                  myTriangle << side1 << side2 << side3;
              
                  QPainter mypainter(this);
                  QPen mypen(Qt::blue);
              
                  mypainter.setPen(mypen);
                  mypainter.drawLines(myTriangle);
              
              PsnarfP 1 Reply Last reply
              0
              • PsnarfP Psnarf

                I'm teaching myself how to draw lines. I gave up on the player example after I switched from full-screen esc back to normal and the player window detached, playing in a small box in the upper left corner of the screen while the player window had static wide black and white lines in it.
                This is what generated the above. No doubt better ways to do it, but it's a start.

                Widget::Widget(QWidget *parent) :
                    QWidget(parent),
                    ui(new Ui::Widget)
                {
                    ui->setupUi(this);
                }
                
                Widget::~Widget()
                {
                    delete ui;
                }
                
                void Widget::paintEvent(QPaintEvent *e)
                {
                    // Base triangle
                    qreal myWidthF  = this->width();
                    qreal myHeightF = this->height();
                
                    QPointF pt1, pt2, pt3;
                    pt1.setX(0 + 1);
                    pt1.setY(myHeightF - 1);
                    pt2.setX(myWidthF/2 + 1);
                    pt2.setY(0 + 1);
                    pt3.setX(myWidthF - 1);
                    pt3.setY(myHeightF - 1);
                
                    QLineF side1, side2, side3;
                    side1 = QLineF(pt1, pt2);
                    side2 = QLineF(pt2, pt3);
                    side3 = QLineF(pt3, pt1);
                
                    QVector<QLineF> myTriangle;
                    myTriangle << side1 << side2 << side3;
                
                    QPainter mypainter(this);
                    QPen mypen(Qt::blue);
                
                    mypainter.setPen(mypen);
                    mypainter.drawLines(myTriangle);
                
                PsnarfP Offline
                PsnarfP Offline
                Psnarf
                wrote on last edited by
                #7

                ...the rest. Next phase is to use recursion to make a Sierpinski Triangle.

                // Inner triangle
                pt1.setX(pt1.x() + side1.dx()/2);
                pt1.setY(pt1.y() + side1.dy()/2);
                
                pt2.setX(pt2.x() + side2.dx()/2);
                pt2.setY(pt2.y() + side2.dy()/2);
                
                pt3.setX(pt3.x() + side3.dx()/2);
                pt3.setY(pt3.y() + side3.dy()/2);
                
                side1 = QLineF(pt1, pt2);
                side2 = QLineF(pt2, pt3);
                side3 = QLineF(pt3, pt1);
                myTriangle.clear();
                myTriangle << side1 << side2 << side3;
                
                mypainter.setPen(Qt::red);
                mypainter.drawLines(myTriangle);
                
                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