Kaynağa Gözat

Preserve button ids in ctkButtonGroup

Julien Finet 10 yıl önce
ebeveyn
işleme
f5a5c3b480
1 değiştirilmiş dosya ile 2 ekleme ve 1 silme
  1. 2 1
      Libs/Widgets/ctkButtonGroup.cpp

+ 2 - 1
Libs/Widgets/ctkButtonGroup.cpp

@@ -64,9 +64,10 @@ void ctkButtonGroup::onButtonClicked(int buttonId)
   // here the button is clicked and we click it again... so we want to
   // here the button is clicked and we click it again... so we want to
   // uncheck, a behavior not supported by QButtonGroup.
   // 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
   // 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);
   this->removeButton(clickedButton);
   clickedButton->setChecked(false);
   clickedButton->setChecked(false);
-  this->addButton(clickedButton);
+  this->addButton(clickedButton, oldId);
   d->IsLastButtonPressedChecked = false;
   d->IsLastButtonPressedChecked = false;
 }
 }