I've got a group of radio buttons. These are all connected to the same SLOT(updateImage())
.
Here's how they are set up:
connect(m_radio1, SIGNAL(toggled(bool)), this, SLOT(updateImage());
connect(m_radio2, SIGNAL(toggled(bool)), this, SLOT(updateImage());
connect(m_radio3, SIGNAL(toggled(bool)), this, SLOT(updateImage());
When changing the radio button from one to the next, this SLOT()
is called twice, once for de-selecting the previously selected radio button, and once for selecting the clicked radio button.
I was wondering, is there a way to modify my SLOT()
to only occur in one of these cases, when the clicked item becomes checked?
Thanks
You are asking to connect to the toggled signal - you are called whenever the object is toggled. What's surprising?
You could connect to the "clicked" signal which provides a "checked" argument you can test.
Btw; if using a modern Qt version, you should ditch the SIGNAL and SLOTS macros and instead use the new connect() syntax that's checked at compile time.