确定按钮无法在QDialog上运行

时间:2015-04-15 19:50:07

标签: c++ qt qdialog

我正在使用C ++ / Qt编写应用程序我使用设计工具设计了一个Qdialog框。

对话框的定义如下。

c ++文件

#include "dialogwarning.h"
#include "ui_dialogwarning.h"

DialogWarning::DialogWarning(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DialogWarning)
{
    ui->setupUi(this);
}

DialogWarning::~DialogWarning()
{
    delete ui;
}

头文件

#include <QDialog>

namespace Ui {
class DialogWarning;
}

class DialogWarning : public QDialog
{
    Q_OBJECT

public:
    explicit DialogWarning(QWidget *parent = 0);
    ~DialogWarning();

private:
    Ui::DialogWarning *ui;
};

来源使用如下:

WarningDialog = new DialogWarning();
QLabel *label = new QLabel("File/Folder name already exist", WarningDialog);
label->setGeometry(WarningDialog->rect().center().x() - label->rect().width()/2,
                   WarningDialog->rect().center().y() - label->rect().height()*2,
                   WarningDialog->rect().width(),
                   WarningDialog->rect().height());
WarningDialog->exec();

我正在使用exec而不是show,因为exec原语允许我被卡在对话框中,直到按下“Ok”按钮。

奇怪的是OK按钮不起作用。我不需要任何特定的行为,只需等待OK按继续运行代码。

由于

1 个答案:

答案 0 :(得分:0)

我不确定假设你已经连接了所有东西。可能是申请被冻结了。

为什么不将计算放在不同的线程中,并将显示对话框的相同信号连接到线程暂停。

应连接ok按钮的信号以关闭对话框和线程恢复......

相关问题