QPushButton remains pressed if QFileDialog is invoked in its slot
-
26-04-2021 - |
Вопрос
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?
Решение
I found that using the slot name:
on_mybutton_clicked()
instead of
on_mybutton_pressed()
Fixes this problem.
Не связан с StackOverflow