Stretch/Resize background image of QTableWidgetItem
-
Hi,
I have a new question for you :)
In a QTableWidget, I create QTableWidgetItems with a backgroung image.
I would like as the image resize with the size of the QTableWidgetItem.I change the size of the cells but the image never resizing.
I can not do it...
Objet = QTableWidgetItem() Objet.setData(Qt.BackgroundRole, QBrush(Img))
I prefere do not use QLabel with stretch...
Any idea ?
Thank you.
EDIT :
For the moment, I use the resizeEvent of the QTableWidget and resend all pixmap with the good width.
That works but seems heavy... -
Hi
did you try to scale Img ?
Objet.setData(Qt.BackgroundRole, QBrush(Img.scaled(xx))) -
@hizoka
Hi
I never saw such option to have it do it automatically.
You could try with a delegate
https://stackoverflow.com/questions/7416503/howto-draw-border-for-qtablewidget-row
where you handle the drawing of the img yourself.Maybe someone knows an easier way :)