gpt4 book ai didi

c++ - 是什么导致我在 Qt 中的第一次机会(堆栈溢出)异常?

转载 作者:行者123 更新时间:2023-11-30 02:34:21 25 4
gpt4 key购买 nike

我有一个 QComboBox,它应该在 CurrentTextChanged 上更新。我创建了以下连接语句,以便 QComboBox 触发 onFilterComboBoxCurrentTextChanged 插槽:

connect(m_viewController->getFilterWindow()->getFilterComboBox(), &QComboBox::currentTextChanged, this, &MainController::onFilterComboBoxCurrentTextChanged);

clearAndAddDICOMTagsToShownTagsListWidget 导致以下错误。我该如何解决这个问题?

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).

enter image description here

最佳答案

递归看起来像这样:

  1. 组合框中的文本更改
  2. 你调用 clear(它会导致文本改变)
  3. 回到 1 - 递归就绪。

如果您在执行操作时需要停止信号传播,请在您的组合框对象上调用 blockSignals。但是,我真的会重新考虑您的应用程序逻辑。我经常使用 Qt,不需要经常使用 blockSignals。

关于c++ - 是什么导致我在 Qt 中的第一次机会(堆栈溢出)异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34587879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com