0

What I want to do is to load .svg file and show (render) it in qtableWidget cell. First part I've done like this:

svgWidget = QSvgWidget("C:\mySVG.svg")
svgWidget.setMaximumSize(100,100)

next line renders svg like what I expected:

widget.show()

but when I've tried this:

self.ui.tableWidget.setItem(i, j, QtGui.QTableWidgetItem(svgWidget))
self.ui.tableWidget.setItem(i, j, svgWidget)

neither of those lines inserts svgWidget in tableWidget cell. How should I do that? Examples would be appreciated, I'm still a noob.

Aleksandar
  • 3,541
  • 4
  • 34
  • 57

1 Answers1

1

this should work:

self.ui.tableWidget.setCellWidget(i, j, svgWidget)
Ashwani Kumar
  • 215
  • 1
  • 4
  • That's it, thank you. I have one more problem now: in other columns I have some text and `self.ui.tableWidget.resizeRowsToContents()` stretches height of svgWidget . Is there a way to add white space in cell so `resizeRowsToContents()` do not affect svgWidget, or to lock aspect ratio of svgWidget? I've googled and tried second one, but unsuccessfully(nothing happened): `qsp = QSizePolicy(QSizePolicy.Preferred,QSizePolicy.Preferred) qsp.setHeightForWidth(True) svgWidget.setSizePolicy(qsp)` – Aleksandar Oct 12 '12 at 15:00