创建了一个QMessageBox,当我按下“开始”按钮时会出现我的申请表上的按钮。
当按下任一按钮(确定或取消)时 - 我希望消息框关闭 - 但应用程序保持打开状态。
不幸的是,当我点击Ok或Cancel时,整个应用程序关闭。有什么提示吗?
Ĵ
这是我的代码:
var brush = d3.brush().extent([[0, 0], [width, height]]).on("end", brushended),
idleTimeout,
idleDelay = 350;
svg.append("g")
.attr("class", "brush")
.call(brush);
function brushended() {
var s = d3.event.selection;
if (!s) {
if (!idleTimeout) return idleTimeout = setTimeout(idled, idleDelay);
yscale.domain(d3.extent(data, function(d) { return +d.rank; })).nice();
xscale.domain(d3.extent(data, function(d) { return +d.student_percentile; })).nice()
} else {
xscale.domain([s[0][0], s[1][0]].map(xscale.invert, xscale));
yscale.domain([s[1][1], s[0][1]].map(yscale.invert, yscale));
svg.select(".brush").call(brush.move, null);
}
zoom();
}
function idled() {
idleTimeout = null;
}
function zoom() {
var t = svg.transition().duration(750);
svg.select(".x axis").transition(t).call(xAxis);
svg.select(".y axis").transition(t).call(yAxis);
// apply new scale to the svg elements that depend on scale.
svg.selectAll("text").transition(t)
.attr("x", function(d) {
return xscale(+d.student_percentile);
})
.attr("y", function(d) {
return yscale(+d.rank);
})
}
完整代码:
Main.cpp:
#include "openingdialog.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Dialog w;
w.show();
return a.exec();
}
Opening Dialog:
patientsetup::patientsetup(QWidget *parent) :
QDialog(parent),
ui(new Ui::patientsetup)
{
ui->setupUi(this);
connect(ui->okButton, SIGNAL(clicked()), this, SLOT(confirmButtonClicked()));
connect(ui->ACSMode, SIGNAL(clicked()), this, SLOT(ACSButtonClicked()));
connect(ui->PromptMode, SIGNAL(clicked()), this, SLOT(PMPSAIButtonClicked()));
connect(ui->FullMode, SIGNAL(clicked()), this, SLOT(PMPSFullbuttonClicked()));
}
void patientsetup::PMPSAIButtonClicked()
{
direct = new pmps_f(this);
direct->setData(patient, ui->Weight->value(), ui->Height->value(), lbmvalue, bsavalue, gender);
direct->show();
}
pmps_f MainWindow
pmps_f::pmps_f(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::pmps_f)
{
ui->setupUi(this);
connect(ui->startbutton,SIGNAL(clicked(bool)), this, SLOT(start()));
}
void pmps_f::start()
{
QMessageBox msgBox;
msgBox.setText("Pressing continue will start the process with the process");
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
int ret = msgBox.exec();
switch(ret) {
case QMessageBox::Ok:
msgBox.close();
break;
case QMessageBox::Cancel:
msgBox.close();
break;
}
}
答案 0 :(得分:0)
我设法使用以下方法解决问题:
setQuitOnLastWindowClosed(假);
然而 - 现在,当窗口“x&#39;”时,程序无法正常退出。按钮被推......
有人可以帮忙吗?