[PyQt] comboBox inside a statusBar

kib2 kib2 at free.fr
Wed Nov 7 18:56:23 GMT 2007


alteo_gange a écrit :
> Le mercredi 07 novembre 2007, kib2 a écrit :
>> For the moment, I use the "currentIndexChanged(int)"'s SLOT wich feets
>> my needs, but I wanted to work with string, not int values.
> 
> Hi,
> 
> #!/usr/bin/python
> # -*- coding: Utf-8 -*-
> 
> import sys
> from PyQt4.QtGui import *
> from PyQt4.QtCore import *
> 
> class Widget(QWidget):
> 	def __init__(self):
> 		QWidget.__init__(self)
> 		
> 		hbox=QHBoxLayout()
> 		
> 		combo = QComboBox()
> 		lst=["a","b","c","d","e"]
> 		for i in lst:
> 			combo.addItem(i)
> 		hbox.addWidget(combo)
> 		self.connect(combo,SIGNAL("activated(QString)"),self.changerItem)
> 		self.setLayout(hbox)
> 	
> 	def changerItem(self,i):
> 		print i
> 
> 
> app = QApplication(sys.argv)
> main = Widget()
> main.show()
> sys.exit(app.exec_())
> 

Thanks: that works perfectly :)


More information about the PyQt mailing list