作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 QDialog 代码中,我有以下内容:
QTimer::singleShot(2 * 1000, [&] {
if (theme_download_label) {
theme_download_label->hide();
theme_download_label->setText("text");
}
});
theme_download_label->setText
崩溃。如何处理?
theme_download_label
至
Q_NULLPR
在
close()
之前方法无效。
最佳答案
QObject
的解决方案都是相同的。 . QObject
连接的上下文。当上下文对象死亡时,它会断开连接,因此不会调用仿函数。 this
.这是坠机的可能原因。 theme_download_label
为空:不可能。这是与上下文对象连接的不变量:设计保证上下文对象是事件的。QTimer::singleShot(2 * 1000, theme_download_label, [label = theme_download_label] {
label->hide();
label->setText("text");
});
关于qt - 如何在 QTimer 中检查 QtDesigner 生成的小部件点的有效性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44444105/
我是一名优秀的程序员,十分优秀!