PDA

View Full Version : Send custom Signal when QComboBox item/index is changed



Thibaut
4th February 2021, 10:45
Hi!

I have a quick question, and didn't find a clear answer anywhere.

Basically, the user can click on a button that add/remove a QComboBox on the screen. All the combobox have the same items, and none are different from another. I create my own custom class based on the original QCombobox, and add an ID number.

My question is: is it possible to override the signal send when the selected item in the combobox is changed?
I want to connect my combobox to a slot, and when the user select a particular item in it, be able to print something like "The combobox number 3 has changed!".
Well, I want to do more than that, but that's the basic idea.

I already did the same thing with custom QButton (by overriding the MouseReleaseEvent()), but here I need to use QComboBox and don't see how to reproduce it.

Lesiok
4th February 2021, 10:58
Read about QObject::sender and QSignalMapper. You can apply one of these solutions.