Results 1 to 5 of 5

Thread: How to read QStringList character by character

  1. #1
    Join Date
    Oct 2008
    Location
    Thodupuzha, a small town in kerala
    Posts
    31
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default How to read QStringList character by character

    Masters,

    I have a QStringList and I want to read from it one character at a time (just like using getch() from files). I am using qt 3.3 . Can anybody help me out . Thanking you..

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to read QStringList character by character

    try this
    Qt Code:
    1. list << "abc" << "def";
    2.  
    3. for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
    4. const QString str = *it;
    5. for (int i = 0; i < str.length(); ++i)
    6. cout << str.at(i);
    7. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Oct 2008
    Location
    Thodupuzha, a small town in kerala
    Posts
    31
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to read QStringList character by character

    Thanks spirit...It is reading character by character. But it is not reading end of line character('\n'). How can we modify the code so that we can read end of line character also..Thanking you again...

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to read QStringList character by character

    for docs
    ... The QChar array of the QString (as returned by unicode()) is generally not terminated by a '\0'. If you need to pass a QString to a function that requires a C '\0'-terminated string use latin1()...
    read this for more info.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Oct 2008
    Location
    Thodupuzha, a small town in kerala
    Posts
    31
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to read QStringList character by character

    Thanks spirit ....That did it.....Thank you very much.....

Similar Threads

  1. QIODevice read()
    By ShaChris23 in forum Newbie
    Replies: 1
    Last Post: 3rd May 2007, 01:29

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.