[PyQt] QTreeWidget - itemClicked

Julio César Gázquez jcglists at igneosoluciones.com.ar
Fri Jun 25 02:06:15 BST 2010

El Jue 24 Jun 2010, Jose Vargas Paz escribió:
>  have a problem with SLOT,
>  el slot se activa muchas veces

That is, "the slot activates many times" :-)

>  this is my code:
>  def add_item(self):
>          mdi = self.mdiArea.activeSubWindow()
>          mdi.setWindowModified(True)
>          tree = mdi.widget().treeRequirements
>          item = QTreeWidgetItem (tree)
>          item.setText (0, str("item"))
>          self.connect(tree, SIGNAL("itemClicked(QTreeWidgetItem *, int)"),
>  self.show_widget)
>  if I have five items in my QTreeWidget and I click one of them, the slot
>  "show_widget" also runs five times

You must connect the slot just once, not in add_item but where you setup your 
QTreeWidget,  as the signal comes from the tree, not from the item, and use 
the second parameter in the slot to know what item you clicked.

If you prefer some help in Spanish, drop me a line to julio@, or join PyAr 
mailing list, you'll find a lot of good guys willing to help.

Julio César Gázquez - Ingeniero en Sistemas
Igneo Soluciones
Redes - Asesoramiento - Desarrollos y Sistemas
www.igneosoluciones.com.ar - Tel: (341)-155-705517

More information about the PyQt mailing list