Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, March 2002
QString::section()


Message 1 in thread

Hello,

When coding an IRC library for general public usage using Qt, I've noticed 
that when doing:

	QString message = line.section(':', 2);

With line being "PRIVMSG #blahtestblah :                hi", section() seems 
to strip white space. The resulting string is "hi". That is *wrong*. It 
should include the whitespace since my delimiter isn't a space. What am I 
doing wrong, or is this a bug?

				-- Nick Betcher


Message 2 in thread

Nick,

Try QStringList::split().

Of course, string manipulation is simple enough in Qt that you could also use 
QString::find() and QString::mid() to do things manually.

-Justin

On Tuesday 05 March 2002 13:31, you wrote:
> Hello,
>
> When coding an IRC library for general public usage using Qt, I've noticed
> that when doing:
>
> 	QString message = line.section(':', 2);
>
> With line being "PRIVMSG #blahtestblah :                hi", section()
> seems to strip white space. The resulting string is "hi". That is *wrong*.
> It should include the whitespace since my delimiter isn't a space. What am
> I doing wrong, or is this a bug?
>
> 				-- Nick Betcher