我在Qt中使用这个按钮点击:
QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"),
QString(),
tr("(*.csv));打开保存表单需要3-4秒。为什么?如何提高速度?
发布于 2018-01-21 16:33:20
尝试将此插槽连接到QPushButton:
void MainWindow::openFD(){
QTime myopentime=QTime::currentTime();
for (int i=0;i<1000000;i++) ;//comment out this line for the real test
QString fileName = QFileDialog::getSaveFileName(this,QString(),QString(myopentime.toString("m.s.zzz")+" "+QTime::currentTime().toString("m.s.zzz"))
,tr("*.csv") );
}然后尝试在有或没有count部分的情况下运行它。
您将看到,count部分添加了一些ms...如果没有它,在filename place中显示的时间甚至不会有ms (毫秒)的差异。
所以,你必须在你的代码中搜索其他地方,或者给我们一个更好的例子。
PS: 1)您需要:
#include <QTime>2) counting这一行是为了告诉你我的方法是有效的(因为在取消注释时你会看到一些不同)
结果和答案:如果这个测试不会给出不同之处,那么问题不是在QFileDialog上,而是在代码中的其他地方,或者可能是在操作系统的窗口管理器中。
https://stackoverflow.com/questions/48357832
复制相似问题