0

well I'm using Pyqt4 in Maya2012 to make a reference editor alike ui. I working with a QtableWidget to make the reference list and i have subwidgets in each cell. One of the widgets is a checkbox that unload or reload the reference. The problem i have is if a click directly in the checkbox without have the cell selected it doesn't do anything

this is my code:

 def listConnections(self):

    self.pos=self.sender().currentRow()

    wid = self.list.ref_l.cellWidget(self.pos, 0).children()

    self.text = self.list.list[self.pos]
    self.ref()

    for wt in wid:
        if type(wt)== type(QCheckBox()):
            wt.stateChanged.connect(self.changeState)

        if type(wt)== type(QComboBox()):
            wt.currentIndexChanged.connect(self.changeType)

I'm calling the function with a "itemSlectionChanged" signal because is the only way i knew i could detect the subwidgets. All the subwidgets are made in the moment i fill the list.

Is there a way to make what i want?

Edit:

This is how i called the function

self.list.ref_l.itemSelectionChanged.connect(self.listConnections)

and this is how i create all the subwidgets in the cells

 def fillList(self):
    mayaRef = self.findRef()

    if len(mayaRef)>0:
        for count in range(0,len(mayaRef)):

            self.ref_l.insertRow(count)

            wid=QWidget()
            cLayout=QHBoxLayout()
            wid.setLayout(cLayout)

            checkWid=QCheckBox()

            nameWid=QLabel()

            cLayout.addWidget(nameWid)

            nameWid2=QLabel()

            cLayout.addWidget(nameWid2)

            comWid=QComboBox()
            cLayout.addWidget(comWid)

            self.ref_l.setCellWidget(count,0,wid)

self.ref_l is my QTable Widget, this is in another code that i'm calling with self.list in the original

  • _it doesn't do anything_ Is the changeState slot not getting called? What do you mean by _I'm calling the function with a "itemSlectionChanged" signal_? You might be interested in this: http://stackoverflow.com/questions/1063734/pyqt-consolidating-signals-to-a-single-slot – Andreas Haferburg May 21 '13 at 18:48
  • " What do you mean by I'm calling the function with a "itemSlectionChanged" signal? "- I mean that i call to this function each time i select a diferent cell Item. And the ChangeState get called only if i had the cell Selected, but if i press direct the checkButton it doesn't get called. – Alfredo Díaz May 21 '13 at 19:16

1 Answers1

0

You should set up all your connections right after you create the check boxes in fillList. Each item is associated with the path of the reference. You can use a QSignalMapper to map each check box to the path, then connect the signal mapper to your changeState slot. The signal mapper then calls that slot with the path you specified.

Andreas Haferburg
  • 5,189
  • 3
  • 37
  • 63
  • Thx, i think this should work, but i have to change some of my code to work. Do you have any example of QSignalMapper use, i search for some examples, but i can't completely understand it – Alfredo Díaz May 21 '13 at 22:21
  • What about [this](http://pysnippet.blogspot.de/2010/06/qsignalmapper-at-your-service.html)? Which part didn't you understand? If you're having trouble with it, post the code you have, possibly in another question. – Andreas Haferburg May 22 '13 at 05:54