首先,对于上下文,我将来自triggered
的信号从QAction连接到fileOpen
中名为this
的插槽,其他类似的连接在我的主窗口中的方法中完成类如下:
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()));
}
要显示文件对话框,QFileDialog::getOpenFileName
中使用静态方法MainWindow::fileOpen
:
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_fileOpen
和fileOpen
之间的信号槽连接工作并显示文件对话框,但在关闭对话框后,窗口在调整大小时需要更长时间才能重绘。
为什么会发生这种情况,我该如何解决?
答案 0 :(得分:0)
我所要做的就是在发布模式下构建我的Qt应用程序,这意味着删除" CONFIG + = debug"来自qmake调用的参数。
在发布模式下,性能下降已经消失,这很好,虽然我不明白Qt库的调试和发布版本之间的差异是否允许这种情况发生。