Ahmad
5th May 2007, 01:30
Can anyone guide me,
i have created my MainWindow and in its constructor i call a Dialog window named LoginWindow which inherits QDialog, this Dialog is modal and made of two lineEdits and three Buttons my problem is that i want when user clicks the "validerButton", i can transfer the texts typed by the user in the LineEdits to my MainWindow from where i called this Dialog.
this is my MainWindow s constructor
MainWindow::MainWindow()
{
createActions();
createMenus();
createToolBars();
createStatusBar();
readSettings();
//this is where my problem starts
login = new Loginwindow(this);
login->show();
//i tried this but i get a segmentation error
connect (login->validerButton, SIGNAL(clicked()), this, SLOT(getNames()));
}
void MainWindow::getNames()
{
QString text;
text = login->getNumetudLineEdit();
}
i send u also my LoginWindow
Loginwindow::Loginwindow(QWidget * parent) : QDialog (parent)
{
//construction des labels et des lignes edit
NumetudLabel = new QLabel(tr("&Numero Etudiant:"));
NumetudLineEdit = new QLineEdit;
NumetudLabel->setBuddy(NumetudLineEdit);
CodesecretLabel = new QLabel(tr("&Code Secret:"));
CodesecretLineEdit = new QLineEdit;
CodesecretLabel->setBuddy(CodesecretLineEdit);
QPushButton * inscriptionButton;
QPushButton * inviteButton;
QPushButton * validerButton;
inscriptionButton = new QPushButton(tr("&S'inscrire"));
inscriptionButton->setDefault(true);
inviteButton = new QPushButton(tr("&Invité"));
validerButton = new QPushButton(tr("&Valider"));
//disposition des layouts
topLeftLayout = new QVBoxLayout;
topLeftLayout->addWidget(NumetudLabel);
topLeftLayout->addWidget(NumetudLineEdit);
topLeftLayout->addWidget(CodesecretLabel);
topLeftLayout->addWidget(CodesecretLineEdit);
rightLayout = new QVBoxLayout;
rightLayout->addWidget(validerButton);
rightLayout->addWidget(inscriptionButton);
rightLayout->addWidget(inviteButton);
rightLayout->addStretch();
//QVBoxLayout *leftLayout = new QVBoxLayout;
//leftLayout->addLayout(topLeftLayout);
mainLayout = new QHBoxLayout;
mainLayout->addLayout(topLeftLayout);
mainLayout->addLayout(rightLayout);
this->setLayout(mainLayout);
this->setWindowTitle(tr("Login"));
this->setModal(true);
this->setSizeGripEnabled(false);
//setFixedHeight(sizeHint().height());
//les signaux et slots
connect(validerButton, SIGNAL(clicked()), this, SLOT(Valider()));
}
Pls help me, it would be nice of u
i have created my MainWindow and in its constructor i call a Dialog window named LoginWindow which inherits QDialog, this Dialog is modal and made of two lineEdits and three Buttons my problem is that i want when user clicks the "validerButton", i can transfer the texts typed by the user in the LineEdits to my MainWindow from where i called this Dialog.
this is my MainWindow s constructor
MainWindow::MainWindow()
{
createActions();
createMenus();
createToolBars();
createStatusBar();
readSettings();
//this is where my problem starts
login = new Loginwindow(this);
login->show();
//i tried this but i get a segmentation error
connect (login->validerButton, SIGNAL(clicked()), this, SLOT(getNames()));
}
void MainWindow::getNames()
{
QString text;
text = login->getNumetudLineEdit();
}
i send u also my LoginWindow
Loginwindow::Loginwindow(QWidget * parent) : QDialog (parent)
{
//construction des labels et des lignes edit
NumetudLabel = new QLabel(tr("&Numero Etudiant:"));
NumetudLineEdit = new QLineEdit;
NumetudLabel->setBuddy(NumetudLineEdit);
CodesecretLabel = new QLabel(tr("&Code Secret:"));
CodesecretLineEdit = new QLineEdit;
CodesecretLabel->setBuddy(CodesecretLineEdit);
QPushButton * inscriptionButton;
QPushButton * inviteButton;
QPushButton * validerButton;
inscriptionButton = new QPushButton(tr("&S'inscrire"));
inscriptionButton->setDefault(true);
inviteButton = new QPushButton(tr("&Invité"));
validerButton = new QPushButton(tr("&Valider"));
//disposition des layouts
topLeftLayout = new QVBoxLayout;
topLeftLayout->addWidget(NumetudLabel);
topLeftLayout->addWidget(NumetudLineEdit);
topLeftLayout->addWidget(CodesecretLabel);
topLeftLayout->addWidget(CodesecretLineEdit);
rightLayout = new QVBoxLayout;
rightLayout->addWidget(validerButton);
rightLayout->addWidget(inscriptionButton);
rightLayout->addWidget(inviteButton);
rightLayout->addStretch();
//QVBoxLayout *leftLayout = new QVBoxLayout;
//leftLayout->addLayout(topLeftLayout);
mainLayout = new QHBoxLayout;
mainLayout->addLayout(topLeftLayout);
mainLayout->addLayout(rightLayout);
this->setLayout(mainLayout);
this->setWindowTitle(tr("Login"));
this->setModal(true);
this->setSizeGripEnabled(false);
//setFixedHeight(sizeHint().height());
//les signaux et slots
connect(validerButton, SIGNAL(clicked()), this, SLOT(Valider()));
}
Pls help me, it would be nice of u