July 6, 2012

DaFranzl DaFranzl
Lab Rat
20 posts

Convert QList<int> to QString

 

Hi,

At the moment i am working on my first big project. But now i’m stuck, i need to convert a QList<int> to a QString. The String should be like this: “int,int,int,int”. I need to convert it for saving the list in a database. I tried it with a QListIterator, but it doesnt work. Hope u understand what i mean;)

1 reply

July 6, 2012

Luca Luca
Ant Farmer
589 posts

  1. QList<int> list;
  2. QString string;
  3. ...
  4. ...
  5. ...
  6. for(int i=0; i<list.size(); i++)
  7. {
  8. string += QString::number(list[i]);
  9. if(i<list.size()-1)
  10.    string += "," ;
  11. }

 
  ‹‹ Does anyone have any success running mysql ODBC connector with QSqlQuery and mac osx 10.7 ?      A Blocking Window ››

You must log in to post a reply. Not a member yet? Register here!