/*!
* FIXME -- This is almost certainly a Qt bug-workaround.
* Changing this widget's parent causes a segfault in QComboBox.
* Start with no parent, set parent, clear parent, set again -> segfault.
* The workaround is to create a new QComboBox and restore its state.
*/
bool event(QEvent *e)
{
if (e->type() == QEvent::ParentAboutToChange)
{
const auto oldIndex = _comboBox->currentIndex();
QStringList oldItems; for (int i = 0; i < _comboBox->count(); i++) oldItems.push_back(_comboBox->itemText(i));
delete _comboBox;
_comboBox = (new QComboBox(this));
layout()->addWidget(_comboBox);
_comboBox->addItems(oldItems);
_comboBox->setCurrentIndex(oldIndex);
}
return QWidget::event(e);
}