I have a QComboBox which should be updated on CurrentTextChanged. I have created the following connect statement so that the QComboBox fires the onFilterComboBoxCurrentTextChanged slot:
connect(m_viewController->getFilterWindow()->getFilterComboBox(), &QComboBox::currentTextChanged, this, &MainController::onFilterComboBoxCurrentTextChanged);
clearAndAddDICOMTagsToShownTagsListWidget causes the following errors. How can I solve this?
void MainController::onFilterComboBoxCurrentTextChanged(QString filterName)
{
m_viewController->clearAndAddFilterNamesToFilterComboBox(m_fileController->loadFilterNamesFromConfigFile());
}
QStringList FileController::loadFilterNamesFromConfigFile()
{
QSettings settings(QDir::toNativeSeparators("C:\\HelloWorld\\Config\\Filter.cfg"), QSettings::IniFormat);
QStringList filtersNames = settings.childGroups();
return filtersNames;
}
void ViewController::clearAndAddFilterNamesToFilterComboBox(QStringList filterNames)
{
m_filterWindow.getFilterComboBox()->clear();
m_filterWindow.getFilterComboBox()->addItems(filterNames);
}
QListWidget* FilterWindow::getShownTagsListWidget()
{
return ui.shownTagsListWidget;
}
First-chance exception at 0x777EAFC0 (ntdll.dll) in DoseView.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x002C2FFC).
Unhandled exception at 0x777EAFC0 (ntdll.dll) in DoseView.exe: 0xC00000FD: Stack overflow (parameters: 0x00000001, 0x002C2FFC).
The recursion looks like this:
If you need to stop signal propagation when you perform your operation call blockSignals
on your combobox object. However, I would really rethink your app logic. I work with Qt a lot, and didn't need to use blockSignals a lot.
The easy fix is to block signals before updating combo box's items. Something like this :
void MainController::onFilterComboBoxCurrentTextChanged(QString filterName) {
combobox->blockSignals(true);
m_viewController->clearAndAddFilterNamesToFilterComboBox(m_fileController->loadFilterNamesFromConfigFile());
combobox->blockSignals(false);
}
But I believe you should be able to prevent it by a better design of your code.
User contributions licensed under CC BY-SA 3.0