Important: Please read the Qt Code of Conduct -

QPainter::begin: Paint device returned engine == 0, type: 1

  • Hi Guys
    I have a QVTKRenderWindowInteractor and wants to draw line on it.
    I pass the QVTKRenderWindowInteractor object to my painter but when i run I got " Painter not active".
    Here is my method :

    # obj is type of QVTKRenderWindowInteractor
    def draw_line(self, obj):
        painter = QPainter(obj)
        # painter.begin(obj)
        painter.drawLine(400, 100, 100, 100)

    Thank You.

  • @KIMIA said in QPainter::begin: Paint device returned engine == 0, type: 1:
    Not my area, but your code is run inside some paintEvent(), right?

    I think your error message comes from QPainter::isActive() returning false. After one of painter = QPainter(obj) or painter.begin(obj) it needs to return true, but you're saying it's still false?

  • Banned

    Well without seeing the code you use to create the object you are passing in -- it is hard to see what you might or might not be doing wrong -- better yet supply an MRE (Minimal Reproducible Example) that shows this functioning and produces the same error you are getting when it is run --- then we can help you troubleshoot your bug so much more effectively and quicker to boot

Log in to reply