View Full Version : QDialog for beginner
mk33
11th March 2009, 17:18
Hello,
I'm begining witt Qt. I have MainWindow and Dialog.
Dialog have a two QLineEdits lineEditLogin and lineEditPassword. How I will get data from this QLineEdits into MainWindow and display on Label in MainWindow?
Thank's you
Sheng
11th March 2009, 17:35
QString text;
text=lineEdit1->text();
label->setText(text);
spirit
11th March 2009, 17:35
add two method to your dialog like these
class MyDialog: public QDialog
{
...
public:
...
QString login() const;
QString password() const;
...
private:
QLineEdit *m_leLogin;
QLineEdit *m_lePassword;
...
};
...
QString MyDialog::login() const
{
return m_leLogin->text();
}
QString MyDialog::password() const
{
return m_lePassword->text();
}
...
void MyMainWindow::showLoginDialog()
{
MyDialog md(this);
if (!md.exec())
return;
const QString login = md.login();
const QString pasword = md.password();
...
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.