[PyQt] Trying insert image into QTableWidget

Hans-Peter Jansen hpj at urpla.net
Thu Aug 4 21:44:30 BST 2011


On Thursday 04 August 2011, 21:45:01 Tony Peña wrote:
> ok nothing yet
> i refresh the code again here with QLabel now.. :|
>
>             airlineCodePath = './airlines/%s.gif' % code_airline
>             try:
>                 if os.path.exists(airlineCodePath) is True:
>                     airline = QtGui.QLabel()
>                     Pixmap = QtGui.QPixmap(airlineCodePath)
>                     airline.fileName = airlineCodePath
>                     col_airline = QtGui.QLabel.setPixmap(Pixmap)
>                     self.ui.PILOT_FullList.setItem(startrow, 0,
> col_airline) else:
>                     code_airline = '-'
>                     col_airline =
> QtGui.QTableWidgetItem(code_airline, 0)
> self.ui.PILOT_FullList.setItem(startrow, 0, col_airline)
>
>             except:
>                 pass
>
> someone can made simple table 1x1 with a simple .gif, .png or .jpg
> example???

From a cursory look, you seem to forgot to hold a reference to your 
label. Try:

	airline = QtGui.QLabel(self)
	pixmap = QtGui.QPixmap(airlineCodePath)
	airline.setPixmap(pixmap)

Vincent questioned your catch all exception handler already..
It's hard to make some sense from your snippets. Try to provide a 
minimum runnable example, if you're after substantial help.

Pete


More information about the PyQt mailing list