c – Qt:某些插槽不会在发布模式下执行

我在Qt(MSVC 2008)中做了一些简单的程序,只有很少的复选框和按钮.在调试模式下,一切正常,但我不能分发这样的可执行文件,因为大多数人没有安装Visual Studio.当我在发布模式下编译它时,只有2个按钮工作.

我使用Qt Creator的’绘图工具’设计了我的窗口(Qt Designer,我猜).
我的头文件中定义了这样的插槽:

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 *);

我对这些信号的实现如下:

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"),tr("Text files (*.txt);;All files (*)"));
    if (filename.size() == 0)
        return;
    else
        ui->inputEdit->setText(filename);
}

请原谅我的英语,并提前感谢你.

解决方法

你的代码看起来不错.

尝试运行“make clean”或“qmake”.您的“ui_”或“moc_”文件可能需要更新.

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...