How can i prepend the string in the list of string?



  • I have a list QList<QString>list;
    Initially i have inserted some string in the list, afterwards i want to prepend some data in the each string in the list. I have tried the following code but getting error
    @
    for (int count = 0; count < list.size (); count ++) {
    list.at (count).prepend (temp_string);
    }
    @

    How can i achieve it?



  • maybe

    (list.at (count)).prepend (temp_string);

    Frederic



  • .at(int i) returns a const reference, you need to use the [] operator if you want to change the returned reference.
    @
    for (int count = 0; count < list.size (); count ++) {
    list[count].prepend (temp_string);
    }
    @



  • [quote author="KA51O" date="1331644359"].at(index) returns a const reference you need to use the [index] operator if you want to change the returned data.
    @
    for (int count = 0; count < list.size (); count ++) {
    list[count].prepend (temp_string);
    }
    @[/quote]

    Thanks now it is working.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.