Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QPainter::begin: Paint device returned engine == 0, type: 1
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved Qt for Python
qt for pythonpython
2 Posts 3 Posters 3.3k 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.
  • K Offline
    K Offline
    KIMIA
    wrote on last edited by
    #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.setRenderHint(QPainter.Antialiasing)
    
        painter.setPen(QtCore.Qt.red)
    
        painter.setBrush(QtCore.Qt.white)
    
        painter.drawLine(400, 100, 100, 100)
    

    Thank You.

    JonBJ 1 Reply Last reply
    0
    • K KIMIA

      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.setRenderHint(QPainter.Antialiasing)
      
          painter.setPen(QtCore.Qt.red)
      
          painter.setBrush(QtCore.Qt.white)
      
          painter.drawLine(400, 100, 100, 100)
      

      Thank You.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @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?

      1 Reply Last reply
      1

      • Login

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