[Qt-interest] Process_line
Donal O'Connor
donaloconnor at gmail.com
Mon Nov 9 17:40:06 CET 2009
Yes, convert to QString and used the trimmed method()
http://doc.trolltech.com/4.5/qstring.html#trimmed
QByteArray line;
QString lineStr = QString(line).trimmed();
On Mon, Nov 9, 2009 at 4:37 PM, Gian Marco Gallo
<gianmarco.gallo at gmail.com>wrote:
> If in the file I write this:
> "New game
> Options
> Manual
> Quit"
>
> it reads the first line as "new game
> "(untill the return space)
> the second line as "options "
> the third line as "manual "
> and the fourth as "quit" (because there isn't a return space)
>
> But I want to read only "new game","options","manual","quit". Is it
> possible?
>
> Il giorno 09/nov/2009, alle ore 17.34, Donal O'Connor ha scritto:
>
> I don't understand the question....
>
> On Mon, Nov 9, 2009 at 4:33 PM, Gian Marco Gallo <
> gianmarco.gallo at gmail.com> wrote:
>
>> Uhm...Ian T. replied to me in the same way. So now the question is: how
>> can I avoid it read all the line also with the return spaces?
>>
>> Il giorno 09/nov/2009, alle ore 17.29, Donal O'Connor ha scritto:
>>
>> Process line is just an example of a method you might declare to "process"
>> the line.
>>
>> This is a user defined method but it doesn't have to be a method, you can
>> do what ever you want to the line operating on the line QByteArray, for
>> example, convert to a QString and do splitting or something....
>>
>>
>>
>> On Mon, Nov 9, 2009 at 4:25 PM, Gian Marco Gallo <
>> gianmarco.gallo at gmail.com> wrote:
>>
>>> Good afternoon
>>>
>>> I'm reading the QFile class definition and there's a part of code that
>>> I'm not able to compile:
>>>
>>> QFile file("in.txt");
>>> if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
>>> return;
>>>
>>> while (!file.atEnd()) {
>>> QByteArray line = file.readLine();
>>> process_line(line);
>>> }
>>>
>>>
>>> In this part of code I can directly read the content of a file but I
>>> don't understand from where process_line method comes out. I've tried to
>>> search if it's a c++ method but it's not, I've tried to search if it's a qt
>>> class method but it's not...so?
>>>
>>> Thanks
>>>
>>>
>>> Gian Marco Gallo
>>>
>>> _______________________________________________
>>> Qt-interest mailing list
>>> Qt-interest at trolltech.com
>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>>
>>>
>>
>> Gian Marco Gallo
>> vACC Italy Director
>> Vatsim Supervisor
>>
>>
>>
>>
>>
>>
>>
>>
>
> Gian Marco Gallo
> vACC Italy Director
> Vatsim Supervisor
>
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091109/c16975f5/attachment.html
More information about the Qt-interest-old
mailing list