Search code examples
pythonpyqt5qpixmap

PyQt5 - How to set QPixmap to black?


I've recently started to learn PyQt5 a bit.

But I'm struggling to set a QPixmap to fully black.

Is there any QPixmap function on how to set it to black?

For example something like self.screen.setPixmap()?


Solution

  • Solved the issue like suggested by musicamente using pixmap.fill(Qt.black):

    from PyQt5.QtCore import *
    
    pixmap = QPixmap(16,16)
    pixmap.fill(Qt.black)  #  fill the map with black
    
    self.screen.setPixmap(pixmap)