Results 1 to 3 of 3

Thread: cannot access QLineEdit text in other methods of the class...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default cannot access QLineEdit text in other methods of the class...

    hi all I have a lil'bit of a problem) which i don't understand...
    i have a class, it;s something like this:

    Qt Code:
    1. class LoginDialog : public QDialog
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. LoginDialog(QWidget *parent = 0);
    7.  
    8. public slots:
    9.  
    10. void loginClicked(char* uname = "test", char* pass = "pass")
    11. {
    12. //QString text = inU->text();
    13. //qDebug() << text
    14.  
    15. char* query;
    16.  
    17. query = (char*)calloc(strlen("SELECT * FROM admin WHERE adm_username='") + strlen(uname) + strlen("' AND adm_password='") + strlen(pass) + strlen("';") + 1, sizeof(char));
    18.  
    19. strcat (query, "SELECT * FROM admin WHERE adm_username='");
    20. strcat (query, uname);
    21. strcat (query, "' AND adm_password='");
    22. strcat (query, pass);
    23. strcat (query, "';");
    24.  
    25. };
    26.  
    27. private:
    28. PGconn* conn;
    29. PGresult* result;
    30.  
    31. QPushButton *okButton;
    32. QPushButton *resetButton;
    33.  
    34. QLineEdit* inU;
    35. QLineEdit* inP;
    36. QString* uText;
    37.  
    38.  
    39. };
    To copy to clipboard, switch view to plain text mode 
    I have a constructor of this class, smth like this:
    Qt Code:
    1. LoginDialog::LoginDialog(QWidget *parent)
    2. : QDialog(parent)
    3. {
    4.  
    5. ...
    6. inU = new QLineEdit;
    7. inP = new QLineEdit;
    8.  
    9. inU->setText("test text");
    10. //*uText = inU->text();
    11.  
    12. ...
    13. this->show();
    14. };
    To copy to clipboard, switch view to plain text mode 
    as you see, I can set the text of the inU, or inP QLineEdits and extract it without problems (extract: inU->text(); and insert: inU->setText("test text") in the constructor, but I cannot access it from other methods (like loginClicked...)... Am I doing something wrong? please someone help... how it can be done?
    Last edited by Leoha_Zveri; 29th September 2009 at 10:39.

  2. #2
    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: cannot access QLineEdit text in other methods of the class...

    include header, like this
    Qt Code:
    1. #include <QLineEdit>
    2.  
    3. class LoginDialog : public QDialog
    4. ...
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Sep 2009
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: cannot access QLineEdit text in other methods of the class...

    it worked! thanks a lot!!!
    by why? I have included the <QtGui> header, i thought it has all i need, no?

Similar Threads

  1. Grey text in empty QLineEdit
    By Mefisto in forum Qt Programming
    Replies: 4
    Last Post: 3rd October 2017, 11:35
  2. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  3. QLineEdit and background text
    By SnarlCat in forum Qt Programming
    Replies: 2
    Last Post: 6th March 2009, 22:17
  4. QLineEdit text() crash - Qt3
    By user_mail07 in forum Qt Programming
    Replies: 7
    Last Post: 10th June 2008, 09:42
  5. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 15:13

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.