Results 1 to 13 of 13

Thread: QDialog and QMainWindow Data Transfer

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2007
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    9

    Default QDialog and QMainWindow Data Transfer

    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
    Qt Code:
    1. MainWindow::MainWindow()
    2. {
    3. createActions();
    4. createMenus();
    5. createToolBars();
    6. createStatusBar();
    7.  
    8. readSettings();
    9.  
    10. //this is where my problem starts
    11. login = new Loginwindow(this);
    12.  
    13. login->show();
    14. //i tried this but i get a segmentation error
    15. connect (login->validerButton, SIGNAL(clicked()), this, SLOT(getNames()));
    16. }
    17.  
    18. void MainWindow::getNames()
    19. {
    20. QString text;
    21. text = login->getNumetudLineEdit();
    22. }
    To copy to clipboard, switch view to plain text mode 

    i send u also my LoginWindow

    Qt Code:
    1. Loginwindow::Loginwindow(QWidget * parent) : QDialog (parent)
    2. {
    3. //construction des labels et des lignes edit
    4.  
    5. NumetudLabel = new QLabel(tr("&Numero Etudiant:"));
    6. NumetudLineEdit = new QLineEdit;
    7. NumetudLabel->setBuddy(NumetudLineEdit);
    8.  
    9. CodesecretLabel = new QLabel(tr("&Code Secret:"));
    10. CodesecretLineEdit = new QLineEdit;
    11. CodesecretLabel->setBuddy(CodesecretLineEdit);
    12.  
    13. QPushButton * inscriptionButton;
    14. QPushButton * inviteButton;
    15. QPushButton * validerButton;
    16.  
    17. inscriptionButton = new QPushButton(tr("&S'inscrire"));
    18. inscriptionButton->setDefault(true);
    19. inviteButton = new QPushButton(tr("&Invité"));
    20. validerButton = new QPushButton(tr("&Valider"));
    21.  
    22. //disposition des layouts
    23. topLeftLayout = new QVBoxLayout;
    24. topLeftLayout->addWidget(NumetudLabel);
    25. topLeftLayout->addWidget(NumetudLineEdit);
    26. topLeftLayout->addWidget(CodesecretLabel);
    27. topLeftLayout->addWidget(CodesecretLineEdit);
    28.  
    29. rightLayout = new QVBoxLayout;
    30. rightLayout->addWidget(validerButton);
    31. rightLayout->addWidget(inscriptionButton);
    32. rightLayout->addWidget(inviteButton);
    33. rightLayout->addStretch();
    34.  
    35. //QVBoxLayout *leftLayout = new QVBoxLayout;
    36. //leftLayout->addLayout(topLeftLayout);
    37.  
    38. mainLayout = new QHBoxLayout;
    39. mainLayout->addLayout(topLeftLayout);
    40. mainLayout->addLayout(rightLayout);
    41. this->setLayout(mainLayout);
    42.  
    43. this->setWindowTitle(tr("Login"));
    44. this->setModal(true);
    45. this->setSizeGripEnabled(false);
    46. //setFixedHeight(sizeHint().height());
    47.  
    48. //les signaux et slots
    49. connect(validerButton, SIGNAL(clicked()), this, SLOT(Valider()));
    50. }
    To copy to clipboard, switch view to plain text mode 

    Pls help me, it would be nice of u
    Last edited by wysota; 5th May 2007 at 09:38. Reason: missing [code] tags

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.