有一个事件:
void MainWindow::OnShow(){
// Start OnShow actions
ui->LoadingBox->setVisible(true);
std::thread dThread(OnShow_threaded, ui, &(this->settingsMap));
dThread.join();
}
有一个函数OnShow_threaded:
void OnShow_threaded(Ui::MainWindow *ui, std::unordered_map<QString,QString> *settingsMap){
// Connect to server
bool hasInternet = true;
// If app doesn't have Internet access -> show offline mode
if (!hasInternet) {
ui->SettingsLabel->setVisible(true);
}
}
编译静态程序集时程序崩溃,出现以下错误:
QCoreApplication::sendEvent 中的 ASSERT 失败:“无法向其他线程拥有的对象发送事件。当前线程 0x0x36c56540。在线程 0x0x341c2fa0 中创建了接收器 'WarningMsg'(类型为 'QGroupBox')”,文件 kernel\qcoreapplication.cpp,行558
在线的:ui->SettingsLabel->setVisible(true);
同时,动态链接也不存在这样的错误。
你能告诉我如何解决这种错误吗?
完整的项目可以在这里查看:GitHub
最佳答案在这里:
https
://stackoverflow.com/questions/66063164/how-can-i-change-gui-from-stdthread PS 是的,用英语 - 如果您不知道,请使用 translate.yandex。 ru 网站