-
Notifications
You must be signed in to change notification settings - Fork 1
/
usefiledelegate.py
29 lines (23 loc) · 993 Bytes
/
usefiledelegate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# This Python file uses the following encoding: utf-8
from PySide2 import QtWidgets
from PySide2.QtWidgets import QStyledItemDelegate
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from resources_rc import *
class UseFileDelegate(QItemDelegate):
def __init__(self, parent=None):
QItemDelegate.__init__(self, parent)
def paint(self, painter, option, index):
icon = QIcon(QPixmap(':/resources/[email protected]'))
painter.save()
line_1x = icon.pixmap(12,12)
painter.drawText( option.rect.adjusted(5,option.rect.height()/2 - 8 , 0, 0), Qt.AlignLeft, index.data())
painter.drawPixmap(option.rect.x()+option.rect.width() - 25,
option.rect.y()+option.rect.height()/2 - 4,
12,
12,
line_1x)
painter.restore()
def sizeHint(self, option, index):
return QSize( option.rect.width(), 24)