Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Convert QList<int> to QString
Forum Updated to NodeBB v4.3 + New Features

Convert QList<int> to QString

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 18.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DaFranzl
    wrote on 6 Jul 2012, 14:01 last edited by
    #1

    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 Last reply
    0
    • L Offline
      L Offline
      luca
      wrote on 6 Jul 2012, 14:05 last edited by
      #2

      @
      QList<int> list;
      QString string;
      ...
      ...
      ...
      for(int i=0; i<list.size(); i++)
      {
      string += QString::number(list[i]);
      if(i<list.size()-1)
      string += "," ;
      }
      @

      1 Reply Last reply
      0

      1/2

      6 Jul 2012, 14:01

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved