Results 1 to 3 of 3

Thread: QDialog for beginner

  1. #1
    Join Date
    Mar 2009
    Posts
    1

    Default QDialog for beginner

    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

  2. #2
    Join Date
    Sep 2008
    Location
    New York
    Posts
    90
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QDialog for beginner

    Qt Code:
    1. QString text;
    2. text=lineEdit1->text();
    3. label->setText(text);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDialog for beginner

    add two method to your dialog like these
    Qt Code:
    1. class MyDialog: public QDialog
    2. {
    3. ...
    4. public:
    5. ...
    6. QString login() const;
    7. QString password() const;
    8. ...
    9. private:
    10. QLineEdit *m_leLogin;
    11. QLineEdit *m_lePassword;
    12. ...
    13. };
    14. ...
    15. QString MyDialog::login() const
    16. {
    17. return m_leLogin->text();
    18. }
    19.  
    20. QString MyDialog::password() const
    21. {
    22. return m_lePassword->text();
    23. }
    24. ...
    25. void MyMainWindow::showLoginDialog()
    26. {
    27. MyDialog md(this);
    28. if (!md.exec())
    29. return;
    30. const QString login = md.login();
    31. const QString pasword = md.password();
    32. ...
    33. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by spirit; 11th March 2009 at 17:42.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. adding QAction to QDialog is not working
    By sanjayshelke in forum Qt Programming
    Replies: 3
    Last Post: 13th August 2008, 09:39
  2. QDialog margin and spacing
    By TheRonin in forum Qt Programming
    Replies: 4
    Last Post: 29th October 2007, 10:11
  3. QDialog / QListView problem
    By harakiri in forum Qt Programming
    Replies: 1
    Last Post: 10th July 2007, 18:31
  4. Resizing a QDialog to the content size
    By Nyphel in forum Qt Programming
    Replies: 8
    Last Post: 15th March 2007, 08:16
  5. Qdialog as a child widget
    By dave in forum Newbie
    Replies: 12
    Last Post: 14th November 2006, 09:43

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.