【发布时间】:2014-06-14 10:08:15
【问题描述】:
我正在尝试为QDialog 实现信号槽系统。在 Google 搜索后,我在 Stack Overflow 上找到了 this question。这个答案看起来很有希望,所以我尝试使用它。我没有收到任何错误,但插槽不起作用。以下是我的代码:
newactivity.cpp
// in the QDialog constructor
QObject::connect(this->ui.createBtn, SIGNAL(clicked()), this, SLOT(accept()));
QObject::connect(this->ui.cancelBtn, SIGNAL(clicked()), this, SLOT(reject()));
void newActivity::accept() {
QDialog::accept(); // to close the dialog and return 1
}
void newActivity::reject() {
QDialog::reject(); // to close the dialog and return 0
}
schedule.cpp
void Schedule::on_actionNew_Activity_triggered() {
newActivity *newActivityWnd = new newActivity(this, Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
newActivityWnd->exec();
QObject::connect(newActivityWnd, SIGNAL(accepted()), this, SLOT(on_activityCreated()));
}
void Schedule::on_activityCreated() {
this->ui.timeLine->hide();
}
这是我的对话:
当我按下New activity 对话框上的Create 按钮时,什么也没有发生。我哪里错了?
【问题讨论】:
标签: c++ qt signals-slots qdialog