Question

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?

Was it helpful?

Solution

I found that using the slot name:

on_mybutton_clicked()

instead of

on_mybutton_pressed()

Fixes this problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top