Results 1 to 3 of 3

Thread: how to access ith element of an qstring list?

  1. #1
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default how to access ith element of an qstring list?

    hi,
    I'm trying to use the following code to iterate the QString List but i'm getting error.
    here list is of type QStringList

    Qt Code:
    1. for (int i = 0; i < list.size(); ++i)
    2. QString element=list.at(i).toLocal8Bit().constData() << endl;
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to access ith element of an qstring list?

    What error?

    I'm guessing that "<< endl" is causing you trouble.

  3. The following user says thank you to Spitfire for this useful post:

    aurora (18th October 2011)

  4. #3
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: how to access ith element of an qstring list?

    Also if you put the QString at position i into another QString you don't need these conversions list.at(i).toLocal8Bit().constData() just write QString element = list.at(i);

Similar Threads

  1. Replies: 9
    Last Post: 8th March 2011, 08:35
  2. Access variable using its name as QString
    By homerun4711 in forum Newbie
    Replies: 3
    Last Post: 22nd December 2010, 09:11
  3. How to access QString characters values
    By rdelgado in forum Newbie
    Replies: 7
    Last Post: 15th November 2010, 14:01
  4. A list of qstring
    By maider in forum Qt Programming
    Replies: 3
    Last Post: 25th November 2009, 12:05
  5. Access an object stored in the list.
    By cbarmpar in forum General Programming
    Replies: 2
    Last Post: 21st September 2008, 20:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.