Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Convert QList<int> to QString

    General and Desktop
    2
    2
    17434
    Loading More Posts
    • 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
      DaFranzl last edited by

      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 Reply Quote 0
      • L
        luca last edited by

        @
        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 Reply Quote 0
        • First post
          Last post