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. "QPaintEngine* MyQWidget::paintEngine() const" Never called!

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 267 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.
  • S Offline
    S Offline
    st.germain
    wrote on last edited by
    #1

    Hi,
    I try to do an offscreen "display" without OpenGL.
    I try to do something similar to this:
    https://parich.us/blog/2019/07/02/qt-widgets-vulkan.html

    Unfortunately, my paintEngine overload is never called.

    For now, I only have
    .hpp:

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

    .cpp:

    QPaintEngine* MyQWidget::paintEngine() const
    {
        qDebug() << "MyQWidget::paintEngine()";
        return m_oTheBackendPixmap.paintEngine();
    }
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent)
    {
        mainWindowWidget = new MyQWidget; 
        this->setCentralWidget(mainWindowWidget);
    ...
    

    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?

    Thanks,

    Stéphane Germain

    1 Reply Last reply
    0
    • S Offline
      S Offline
      st.germain
      wrote on last edited by
      #2

      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.
          setAttribute(Qt::WA_PaintOnScreen);
      

      It was that!

      Thanks
      Stéphane

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

        Hi and welcome to devnet,

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

        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

        • Login

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