如果在其槽中调用 QFileDialog,则 QPushButton 保持按下状态
我在主窗口上有一个简单的 QPushButton。我为它添加了一个插槽:
void MainWindow::on_mybutton_pressed() {
QString file_name = QFileDialog::getSaveFileName(
this,
tr("Saving File"),
QDir::homePath(),
"Text files (*.txt);;Any file (*.*)");
}
但是当 QFileDialog 关闭时,QPushButton 保持按下状态,直到我按下另一个 QPushButton。
我该如何解决这个问题?
I have a simple QPushButton on the MainWindow. I've added a slot for it:
void MainWindow::on_mybutton_pressed() {
QString file_name = QFileDialog::getSaveFileName(
this,
tr("Saving File"),
QDir::homePath(),
"Text files (*.txt);;Any file (*.*)");
}
But when the QFileDialog is closed the QPushButton remains pressed until I press another QPushButton.
How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现使用插槽名称:
而不是
修复此问题。
I found that using the slot name:
instead of
Fixes this problem.