QFileDialog导致我的应用程序响应速度变慢

QFileDialog causes my application to become less responsive

本文关键字:响应速度 应用程序 我的 QFileDialog      更新时间:2023-10-16

首先,就上下文而言,我将来自QAction的triggered的信号连接到this中称为fileOpen的插槽,其他类似的连接在我的主窗口类中的方法中完成,如下所示:

void MainWindow::createActions()
{
    m_fileNew = new QAction("&New", this);
    m_fileOpen = new QAction("&Open", this);
    m_fileExit = new QAction("E&xit", this);
    connect(m_fileNew, SIGNAL(triggered(bool)), this, SLOT(fileNew()));
    connect(m_fileOpen, SIGNAL(triggered(bool)), this, SLOT(fileOpen()));
    connect(m_fileExit, SIGNAL(triggered(bool)), this, SLOT(fileExit()));
}

为了显示文件对话框,在MainWindow::fileOpen中使用了静态方法QFileDialog::getOpenFileName:

void MainWindow::fileOpen()
{
    QString filename = QFileDialog::getOpenFileName(this, tr("Open Audio File"),
                                 "", tr("WAVE Files (*.wav);;All Files (*.*)"));
    if (filename != QString::null) {
        m_fileName = filename;
    }
}

m_fileOpenfileOpen之间的信号槽连接工作并显示文件对话框,但关闭对话框后,窗口在调整大小时需要更长的时间来重新绘制。

为什么会发生这种情况,我该如何解决它?

我所要做的就是在发布模式下构建我的Qt应用程序,这意味着从qmake调用中删除"CONFIG+=debug"参数。

在发布模式下,性能下降消失了,这很好,尽管我不明白Qt库的调试版本和发布版本之间的差异允许这种情况发生。