adutzu89
3rd March 2014, 15:19
I am trying to use the cache to store/retrieve data but I cannot actually figure it out how?
I didn't made a dedicated example for it so I just tested it with a login form, trying to store the user inside the cache and retrieve it on QDialog::exec().
I made a class
class InfoUtil{
public:
QString nUtil;
void setUtil(QString a);
const char* retUtil();
};
void InfoUtil::setUtil(QString a){
nUtil=a;
}
const char* InfoUtil::retUtil(){
return nUtil.toStdString().c_str();
}
Here is the block which checks if the login credentials are ok, and if they are it does emits some signals etc and cache the login user
if(util=="admin" && parola=="admin"){
QCache<const char*,InfoUtil> cache;
iu->setUtil(util);
cache.clear();
cache.insert(iu->retUtil(),iu);
}
util is a string which gets it's data from QLineEdit.
When the connection dialog opens it should have the cached "admin" set to the QLineEdit, but I get symbols.
Here is how I try to retrieve the data and set it to QLineEdit inside the dialog's constructor.
QCache<const char*,InfoUtil> cache;
const char* abc;
cache.take(abc);
txtUtil=new QLineEdit(abc);
I know it's wrong but can someone send me to the right direction?
I didn't made a dedicated example for it so I just tested it with a login form, trying to store the user inside the cache and retrieve it on QDialog::exec().
I made a class
class InfoUtil{
public:
QString nUtil;
void setUtil(QString a);
const char* retUtil();
};
void InfoUtil::setUtil(QString a){
nUtil=a;
}
const char* InfoUtil::retUtil(){
return nUtil.toStdString().c_str();
}
Here is the block which checks if the login credentials are ok, and if they are it does emits some signals etc and cache the login user
if(util=="admin" && parola=="admin"){
QCache<const char*,InfoUtil> cache;
iu->setUtil(util);
cache.clear();
cache.insert(iu->retUtil(),iu);
}
util is a string which gets it's data from QLineEdit.
When the connection dialog opens it should have the cached "admin" set to the QLineEdit, but I get symbols.
Here is how I try to retrieve the data and set it to QLineEdit inside the dialog's constructor.
QCache<const char*,InfoUtil> cache;
const char* abc;
cache.take(abc);
txtUtil=new QLineEdit(abc);
I know it's wrong but can someone send me to the right direction?