Results 1 to 2 of 2

Thread: The problem of paint() function in Qgraphicsitem?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2021
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Unhappy The problem of paint() function in Qgraphicsitem?

    I want to make a function of drawing image content after pressing the mouse. You can draw color and transparent channels

    1:The painter parameter in the paint() function can only display images, but not the contents of the drawing process. So I created a new painter to draw the process.

    2:The whole process of the mouse drawing is very slow and stuck

    3:image size: 10000 * 10000

    python code:
    Qt Code:
    1. # show image
    2. painter.drawPixmap(0, 0, self.__display)
    3.  
    4. # draw image
    5. self.painter = QPainter()
    6.  
    7. self.painter.begin(self.__transparent)
    8. radialGrad = QRadialGradient(self.pos, 50)
    9. radialGrad.setColorAt(0, QColor(255, 0, 255, 255))
    10. radialGrad.setColorAt(1, QColor(255, 0, 255, 0))
    11. brush = QBrush(radialGrad)
    12. self.painter.setBrush(brush)
    13. self.painter.setPen(Qt.NoPen)
    14. self.painter.drawEllipse(self.pos, 50, 50)
    15. self.painter.end()
    16.  
    17. self.painter.begin(self.__display)
    18. if self.__painterMode is 0: # Draw color on image
    19. self.painter.drawImage(0, 0, self.__image)
    20. self.painter.setCompositionMode(QPainter.CompositionMode_SourceAtop)
    21. self.painter.drawImage(0, 0, self.__transparent)
    22. elif self.__painterMode is 1: # Draw alpha on image
    23. self.painter.drawImage(0, 0, self.__image)
    24. self.painter.setCompositionMode(QPainter.CompositionMode_DestinationOut)
    25. self.painter.drawImage(0, 0, self.__transparent)
    26.  
    27. self.painter.end()
    28. self.update()
    To copy to clipboard, switch view to plain text mode 
    Last edited by d_stranz; 14th January 2021 at 20:36. Reason: missing [code] tags

Similar Threads

  1. Replies: 1
    Last Post: 11th April 2015, 12:32
  2. QGraphicsItem paint problem
    By mvbhavsar in forum Newbie
    Replies: 5
    Last Post: 10th February 2015, 08:06
  3. Replies: 0
    Last Post: 15th May 2012, 12:44
  4. Custom QGraphicsItem paint function problem
    By andzero in forum Newbie
    Replies: 1
    Last Post: 12th October 2011, 18:35
  5. Paint QGraphicsItem problem
    By dreamer in forum Qt Programming
    Replies: 3
    Last Post: 23rd June 2008, 18:18

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.