Please nominate your Qt Champions for 2021!

"QPaintEngine* MyQWidget::paintEngine() const" Never called!

  • Hi,
    I try to do an offscreen "display" without OpenGL.
    I try to do something similar to this:

    Unfortunately, my paintEngine overload is never called.

    For now, I only have

    class MyQWidget: public QWidget
        QPixmap m_oTheBackendPixmap;
        QPaintEngine *paintEngine() const override;


    QPaintEngine* MyQWidget::paintEngine() const
        qDebug() << "MyQWidget::paintEngine()";
        return m_oTheBackendPixmap.paintEngine();
    MainWindow::MainWindow(QWidget *parent) :
        mainWindowWidget = new MyQWidget; 

    But my main windows are drawn as before, and I never see my debug message "MyQWidget::paintEngine()"

    Someone can help me to see what I miss?


    Stéphane Germain

  • Don't look for it anymore, I got it.
    For info, far in QWidget doc, we can read:

        //If you are using a custom paint engine without Qt's backingstore,
        //  Qt::WA_PaintOnScreen must be set. Otherwise
        //  QWidget::paintEngine() will never be called;
        //  the backingstore will be used instead.

    It was that!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What version of Qt are you using ?
    What OS are you running ?

Log in to reply