[Qt-interest] Text file manipulation
Phil
phillor at telstra.com
Sat Oct 31 07:52:36 CET 2009
Thank you for reading this.
The following is a simplified version of what I'm trying to achieve.
I have a text file that looks something like this:
fruit, apple, orange, grape
fruit, lemon, quince, pear
vegetable, turnip, pea, onion
The first thing I have done is to read the text file into a QStringList
which gives me one long comma separated string.
Then, say I'm looking for fruit.
I search though the QStringList and place each occurrence of fruit
into a table like this which I display:
apple orange grape
lemon quince pear
So far so good.
Now say I want to change quince to cherry and then save the
original text file with the changed text. This where things get
messy.
I've had to keep a counter of where quince occurred in the
QStringList and replace it with cherry at that index point. It sounds
simple enough but the code has turned out to be quite complicated
and I think there must be a far simpler alternative.
I was thinking along the lines of a two-dimensional QStringList or
QByteArray but achieving either is not obvious to me at the
moment either.
I've spent most of the day on this, can anyone offer any
suggestions?
--
Regards,
Phil
More information about the Qt-interest-old
mailing list