[PyQt] QComboBox in QTableWidget: Determining which was changed

Kyle Altendorf sda at fstab.net
Fri Aug 25 21:27:26 BST 2017


On 2017-08-25 16:11, Eugene Mallay wrote:
> I have a QTableWidget that has a QComboBox in each row (with text in
> the other columns). I've connected a callback to the comboboxes that
> is triggered whenever the combobox is changed. All comboboxes are
> connected to the same method.
> 
> The problem I am having is figuring out how to determine *which*
> specific combobox in the table was triggered. Is there a way to
> determine the cell the user was interacting with which triggered the
> callback?

I work with views and delegates instead of the corresponding 'widget'
widgets.  In my case I use the delegate feature of the views for my
combo boxes.  I think they feed back into the regular path of setting
data via the view.  Does that not apply to QTableWidget?  Do you really
have to have a callback or will it set the value back into the table
item itself?

If not, I do in various places use lambdas, functions, and
functools.partial to attach identifier sorts of information in the path
of signals->slots.

Instead of:
     the_signal.connect(the_slot)

You can:
     p = functools.partial(the_slot, from=the_relevant_object)
     the_signal.connect(p)

And add `from` as a parameter on `the_slot`.

Cheers,
-kyle


More information about the PyQt mailing list