Created
September 20, 2016 17:48
-
-
Save oglops/a87c50412e240347fcee72f80ec1bb99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from PySide.QtCore import * | |
from PySide.QtGui import * | |
class xxxx(QListWidget): | |
def __init__(self, parent=None): | |
super(xxxx, self).__init__(parent) | |
self.installEventFilter(self) | |
# def paintEvent(self, event): | |
# p = QPainter() | |
# p.begin(self.viewport()) | |
# p.setPen(QPen(Qt.black)) | |
# p.fillRect(QRect(0, 1, 20, 20), Qt.red) | |
# p.end() | |
def eventFilter(self, widget, event): | |
if event.type() == QEvent.Paint: | |
p = QPainter() | |
# p.begin(self.viewport()) | |
p.begin(widget) | |
p.setPen(QPen(Qt.red)) | |
p.fillRect(QRect(0, 1, 20, 20), Qt.red) | |
p.end() | |
return True | |
return QListWidget.eventFilter(self, widget, event) | |
if __name__ == '__main__': | |
import sys | |
app = QApplication(sys.argv) | |
view = xxxx() | |
view.show() | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment