문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top