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
Qt Code:
  1. class InfoUtil{
  2. public:
  3. QString nUtil;
  4. void setUtil(QString a);
  5. const char* retUtil();
  6. };
  7.  
  8. void InfoUtil::setUtil(QString a){
  9. nUtil=a;
  10. }
  11. const char* InfoUtil::retUtil(){
  12. return nUtil.toStdString().c_str();
  13. }
To copy to clipboard, switch view to plain text mode 

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
Qt Code:
  1. if(util=="admin" && parola=="admin"){
  2. QCache<const char*,InfoUtil> cache;
  3. iu->setUtil(util);
  4. cache.clear();
  5. cache.insert(iu->retUtil(),iu);
  6. }
To copy to clipboard, switch view to plain text mode 


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.
Qt Code:
  1. QCache<const char*,InfoUtil> cache;
  2. const char* abc;
  3. cache.take(abc);
  4. txtUtil=new QLineEdit(abc);
To copy to clipboard, switch view to plain text mode 

I know it's wrong but can someone send me to the right direction?