One possible solution is to convert the text to 64 bit integer on each "textChanged()" and check/uncheck each checkBox according to the bit value in the number. Adding all checkBoxes to a list makes thing simple:
void MyWidget::textChanged(const QString& text){
const qint64 value = text.toInt64();
for (int i=0 ; i<64 ; ++i){
this->m_checkBoxList[i]->setChecked( test_bit(value,i) );
}
}
void MyWidget::textChanged(const QString& text){
const qint64 value = text.toInt64();
for (int i=0 ; i<64 ; ++i){
this->m_checkBoxList[i]->setChecked( test_bit(value,i) );
}
}
To copy to clipboard, switch view to plain text mode
implementing "test_bit(qint64 value, int bitIndex)" to check a single bit in number is left as an excercise
How to add all checkBoxes to a single list ? You can just hardcode 64 inserts in constructor, or if you have properly named the checkboxes in designer (like "checkBox_0", "checkBox_1", etc.) you can use QWidget::findChildren(const QString& name) method. Remeber that the order is important, so you probably can't simply call "findChildren" with an empty "name".
What to do on each checkBox change ? Kind of inverse of the procedure described above, I think you will figure this out yourself.
Bookmarks