On 10.11.08 09:23:03, Luigi Curzi wrote: > --- Lun 10/11/08, Andreas Pakulat <[EMAIL PROTECTED]> ha scritto: > > > Da: Andreas Pakulat <[EMAIL PROTECTED]> > > Oggetto: Re: [PyQt] Problem with QGraphics > > A: [email protected] > > Data: Lunedì 10 novembre 2008, 09:25 > > On 09.11.08 22:05:47, Luigi Curzi wrote: > > > hello. > > > i have a problem whit qgraphics: i wrote these lines: > > > pixmap = > > QtGui.QPixmap("/media/glorious/datiVari/progettiProgrammazione/bitslaiser/f.jpg") > > > scene = QtGui.QGraphicsScene(QtCore.QRectF(0.0, 0.0, > > 300.0, 300.0)) > > > scene.addPixmap(pixmap) > > > scene.addText("Hello, world!") > > > self.ui.graphicsView.setScene(scene) > > > self.ui.graphicsView.show() > > > > > > graphicsView is a view created whit qt4 designer; > > > i don't receive any error, but it doesn't > > appear anything. > > > in the gui's code i have these lines: > > > self.graphicsView = > > QtGui.QGraphicsView(self.centralwidget) > > > > > self.graphicsView.setGeometry(QtCore.QRect(50,100,741,431)) > > > > > self.graphicsView.setObjectName("graphicsView") > > > > > > do i forget something? what can i do? > > > > Yes, you didn't call setupUi() anywhere. I suggest to > > have a look at the > > designer manual, it explains how ui-files in Qt4 work. You > > need to create a > > QWidget yourself and apply the ui to it to see something. > > Also the > > self.ui.graphicsView.show() is not needed. > > > > excuse me, i wasn't clear: > the lines i posted are in a function (that is in the main class) that is > executed when i click on a button; the gui file, that i created with > qt4-designer, contains setupUi and works, and also other functions connected > with the gui items work. > the lines above don't work with or without "self.ui.graphicsView.show()"; i > use qt/pyqt in debian testing and the file "f.jpg" exists.
Hmm... Ah... I overlooked something, you create local objects for pixmap+scene, both of them are going to be deleted as soon as the function call returns. Which means the graphicsview will have no scene attached to it. So just extend their lifetime by attaching them to self for example. Andreas -- You feel a whole lot more like you do now than you did when you used to. _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
