[PyQt] linking listwidget with Qgraphicsview

klia alwaseem307ster at yahoo.com
Wed Mar 11 13:13:49 GMT 2009




Matt Smith-23 wrote:
> 
>>From the looks of it your list widget has the name of the file you want
> to open and display so what you can do is connect the signal being
> emitted, itemClicked(QListWidgetItem *), and then get the text from the
> item passed with say my_list_item.text().  
> 
>>From that you should be able to make a QPixmap with the file name and
> put that in your graphicscene as a QGraphicsPixmapItem.
> 
> mbs
> 
> there are a couple signals you could use:
> http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qlistwidget.html
> 
>> Message: 2
>> Date: Tue, 10 Mar 2009 05:49:35 -0700 (PDT)
>> From: klia <alwaseem307ster at yahoo.com>
>> Subject: [PyQt] linking listwidget with Qgraphicsview
>> To: pyqt at riverbankcomputing.com
>> Message-ID: <22433529.post at talk.nabble.com>
>> Content-Type: text/plain; charset=us-ascii
>> 
>> 
>> hey guys;
>> 
>> in my application i have Listwidegt and Qgraphics view beside to each
>> other
>> in the interface, my intension is after i list my photos in the
>> listwidget,
>> i want that whenever i click on the photo on listwidget it will be
>> displayed
>> on the graphics view...
>> 
>> Any idea on how to do that?
>> 
>> here's the code of inserting photos into Listwidegt
>> 
>> files = QFileDialog.getOpenFileNames(self, self.trUtf8("Add
>> documentation"),
>> QString("/home"), self.trUtf8("Images (*.png *.tiff *.jpg)")) 
>> 		for file_ in files:
>> 			data = ""
>> 			f = open(file_)
>> 			#data = file.read()
>> 			self.listWidget.addItem(file_)
>> 
>> here's a screen shot of my inquiry 
>> http://www.nabble.com/file/p22433529/Screenshot-MainWindow-1.png 
>> -- 
> 
> 
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> 
Thanks for the hint

but i have QGraphicsview widget not graphicscene, how can i implement
QgraphicsPixmapItem?

so far i came with this, is it correct?
files = QFileDialog.getOpenFileNames(self, self.trUtf8("Add documentation"),
> QString("/home"), self.trUtf8("Images (*.png *.tiff *.jpg)")) 
> 		for file_ in files:
> 			data = ""
> 			f = open(file_)
> 			#data = file.read()
> 			self.listWidget.addItem(file_)
		self.listWidget.setItemSelected(file_)
		self.my_list_item.text(file_)
		self.photosdisplay.addPixmap(file_)

but nothing happened when i clicked?
-- 
View this message in context: http://www.nabble.com/linking-listwidget-with-Qgraphicsview-tp22433529p22454858.html
Sent from the PyQt mailing list archive at Nabble.com.



More information about the PyQt mailing list