我有一个 QDialog,它有两个 lineEdits 和一个按钮。当按下按钮时,我希望 QDialog 关闭,并且我希望 lineEdits 中的值可供我使用。现在,我有以下情况:
void createDialog()
{
QDialog dialog;
QLineEdit *lineEdit1 = new QLineEdit(&dialog);
QLineEdit *lineEdit2 = new QLineEdit(&dialog);
QPushButton *ok = new QPushButton("OK", &dialog);
QVBoxLayout *vLayout = new QVBoxLayout();
vLayout->addWidget(lineEdit1);
vLayout->addWidget(lineEdit2);
vLayout->addWidget(ok);
dialog.setLayout(vLayout);
connect(ok, SIGNAL(clicked()), this, SLOT(processValues()));
dialog.exec();
}
我想知道如何关闭 QDialog 并在 processValues() 函数中访问 lineEdits 的值。谢谢!