Qt: some slots are not running in release mode

I am making a simple program in Qt (MSVC ++ 2008) with a few checkboxes and buttons. In debug mode, everything works fine, but I cannot distribute such an executable file, because most people do not have Visual Studio installed. When I compile it in release mode, only 2 buttons work.

I designed my window using the Qt Creator 'drawing tool (Qt Designer, I think). I have slots defined in my header file:

private slots: void on_goButton_clicked(); // Works fine void on_InputCheckBox_stateChanged(int arg1); // Don't work void on_outputFileCheckBox_stateChanged(int arg1); // Same as above void on_inputBrowseButton_clicked(); // Don't work, since theyre disabled void on_outputBrowseButton_clicked(); // Same as above void replyFinished(QNetworkReply *); 

My implementation of these signals is as follows:

 void MainWindow::on_InputCheckBox_stateChanged(int arg1) { if (arg1 == Qt::Checked) { ui->inputEdit->setEnabled(true); ui->inputBrowseButton->setEnabled(true); } else { ui->inputEdit->setEnabled(false); ui->inputBrowseButton->setEnabled(false); } } void MainWindow::on_outputFileCheckBox_stateChanged(int arg1) { if (arg1 == Qt::Checked) { ui->outputEdit->setEnabled(true); ui->outputBrowseButton->setEnabled(true); } else { ui->outputEdit->setEnabled(false); ui->outputBrowseButton->setEnabled(false); } } void MainWindow::on_inputBrowseButton_clicked() { QString documents = DesktopServices::storageLocation(QDesktopServices::DocumentsLocation); QString filename = QFileDialog::getOpenFileName( this, tr("Select input file"), documents, tr("Text files (*.txt);;All files (*)")); if (filename.size() == 0) return; else ui->inputEdit->setText(filename); } void MainWindow::on_outputBrowseButton_clicked() { QString documents = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); QString filename = QFileDialog::getOpenFileName( this, tr("Select output file"), documents, tr("Text files (*.txt);;All files (*)")); if (filename.size() == 0) return; else ui->inputEdit->setText(filename); } 

Sorry for my english and in advance.

+4
source share
2 answers

Your code looks good.

Try running "make clean" or "qmake". Your ui_ or moc_ files may need to be updated.

+1
source

Are you sure that the slots do not cause - or simply do not do what you expect?

The most common reason β€œit works in debugging but not release” is because of unified variables. In debug mode, variables are usually set to zero, but not in release mode.

Another common problem is debugging macros with side effects. Did you (or some kind of lib) rewrite the connect () call as a debugging macro and did something else in the release?

Time to debug printf ()

+1
source

All Articles