【问题标题】:Qt QFileDialog pops up once moreQt QFileDialog 再次弹出
【发布时间】:2014-03-11 15:34:37
【问题描述】:

我正在开发一个系统,对于 GUI,我更喜欢使用 VisStudio 2012 的 QT 插件。按下浏览按钮后,我使用了文件浏览器,一切正常,我选择了我的文件。在我的文件处理完成后,会弹出另一个文件浏览器......你能帮帮我吗?代码如下:

#include "istorm__v3.h"
#include <QFileDialog>
#include <QMessageBox>
#include "ui_istorm__v3.h"
#include "iStormParser.h"

using namespace std;
iStormParser * isp;
iSTORM__v3::iSTORM__v3(QWidget *parent)
    : QMainWindow(parent)
{
    isp=new iStormParser();
    ui.setupUi(this);
    //ui.pushButton->setAutoDefault(false);
    connect(ui.pushButton, SIGNAL(ui.pushButton.clicked()), this, SLOT(ui.on_pushButton_clicked()));
}

iSTORM__v3::~iSTORM__v3()
{
}

void iSTORM__v3::on_pushButton_clicked()
{
    QString filename = QFileDialog::getOpenFileName(this,
                                                    tr("Choose File"),
                                                    "D:\\Desktop\\iSTORM__v3\\iSTORM__v3\\",
                                                    "C Files (*.c);;H Files (*.h)");

    string tmp=filename.toUtf8().constData();
    unsigned found = tmp.find_last_of("/\\");
    tmp=tmp.substr(found+1);

    string data=isp->run("\\testFiles\\"+tmp);
    ui.textEdit->setText( QString::fromStdString(data));
    return;
}

【问题讨论】:

  • 我怀疑您将按钮连接到 on_pushButton_clicked() 插槽两次。
  • 是的,我通过编码和 UI 编辑器连接它们...谢谢!!!

标签: c++ qt visual-studio-2012 qtgui qmainwindow


【解决方案1】:

如果您将插槽连接到相应的信号两次,或者您在插槽调用中再次发出相同的信号,或者至少在插槽退出后“快速”某处会带来这种用户体验,则可能会发生此问题.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-18
    相关资源
    最近更新 更多