Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    2
    3
    99
    Loading More Posts
    • 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
      st.germain last edited by

      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 Reply Quote 0
      • S
        st.germain last edited by

        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 Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          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 Reply Quote 0
          • First post
            Last post