Browse Source

Merge branch 'add-button-group-button-toggled'

* add-button-group-button-toggled:
  Add QButtonGroup::buttonToggled support
  Preserve button ids in ctkButtonGroup
Julien Finet 10 years ago
parent
commit
ffc12402f4
1 changed files with 6 additions and 3 deletions
  1. 6 3
      Libs/Widgets/ctkButtonGroup.cpp

+ 6 - 3
Libs/Widgets/ctkButtonGroup.cpp

@@ -64,10 +64,15 @@ void ctkButtonGroup::onButtonClicked(int buttonId)
   // here the button is clicked and we click it again... so we want to
   // uncheck, a behavior not supported by QButtonGroup.
   // The only way to uncheck the button is to remove it from the group, and put it back
+  const int oldId = this->id(clickedButton);
   this->removeButton(clickedButton);
   clickedButton->setChecked(false);
-  this->addButton(clickedButton);
+  this->addButton(clickedButton, oldId);
   d->IsLastButtonPressedChecked = false;
+#if QT_VERSION >= 0x050200
+  emit buttonToggled(oldId, false);
+  emit buttonToggled(clickedButton, false);
+#endif
 }
 
 //------------------------------------------------------------------------------
@@ -78,5 +83,3 @@ void ctkButtonGroup::onButtonPressed(int buttonId)
   Q_ASSERT(pressedButton);
   d->IsLastButtonPressedChecked = pressedButton->isChecked();
 }
-
-