Hi,

I am new to Qt programming. I am having a difficulty accessing the QDialog widgets data from the class where QDialog is initiated.

QDialog class has one button and a LineEdit widgets and this class is called from the another class where the LineEdit text is supposed to be used. But I am not able to get the QLineEdit text (Entered by the user) into the variable "newName" shown in the code below. I would be grateful to any help.

My code:


void finder::on_New_Button_clicked()
{
Dialog = new NameDialog();

newName = Dialog->getCname();
}

NameDialog::NameDialog(QWidget *parent) :
QDialog(parent)
{
cname = new QLineEdit;
button = new QPushButton(tr("ok"));
Warning = new QLabel(tr("Plase provide the name to new CoverLetter"));
Warning->hide();
leftLayout = new QHBoxLayout;
leftLayout->addWidget(cname);
leftLayout->addWidget(button);
vlayout = new QVBoxLayout;
vlayout->addLayout(leftLayout);
vlayout->addWidget(Warning);
setLayout(vlayout);
this->setMinimumSize(250,100);
this->setMaximumSize(250,100);
this->show();
connect(button,SIGNAL(clicked()), this, SLOT(readCname()));
}

void NameDialog ::readCname()
{
if(cname->text().isEmpty())
Warning->show();
else{
this->name = cname->text();

this->close();
}
}



QString NameDialog::getCname()
{
return name;
}