PDA

View Full Version : cannot access QLineEdit text in other methods of the class...



Leoha_Zveri
29th September 2009, 11:34
hi all :) I have a lil'bit of a problem) which i don't understand...
i have a class, it;s something like this:



class LoginDialog : public QDialog
{
Q_OBJECT

public:
LoginDialog(QWidget *parent = 0);

public slots:

void loginClicked(char* uname = "test", char* pass = "pass")
{
//QString text = inU->text();
//qDebug() << text

char* query;

query = (char*)calloc(strlen("SELECT * FROM admin WHERE adm_username='") + strlen(uname) + strlen("' AND adm_password='") + strlen(pass) + strlen("';") + 1, sizeof(char));

strcat (query, "SELECT * FROM admin WHERE adm_username='");
strcat (query, uname);
strcat (query, "' AND adm_password='");
strcat (query, pass);
strcat (query, "';");

};

private:
PGconn* conn;
PGresult* result;

QPushButton *okButton;
QPushButton *resetButton;

QLineEdit* inU;
QLineEdit* inP;
QString* uText;


};

I have a constructor of this class, smth like this:



LoginDialog::LoginDialog(QWidget *parent)
: QDialog(parent)
{

...
inU = new QLineEdit;
inP = new QLineEdit;

inU->setText("test text");
//*uText = inU->text();

...
this->show();
};

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?

spirit
29th September 2009, 12:00
include header, like this


#include <QLineEdit>

class LoginDialog : public QDialog
...

Leoha_Zveri
29th September 2009, 13:07
it worked! thanks a lot!!!
by why? I have included the <QtGui> header, i thought it has all i need, no? :eek: