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

Qt-interest Archive, February 2007
QString isEmpty() weirdness


Message 1 in thread

Im returning a QString from a class.  I return
QString("") if the vector element isnt found.
When I test for it on the return:

name = getString();
if (name.isEmpty())
{
	error
}
else
{
	do something
}

I always get the error condition.  I did a cout
on the thing:

cout << "<" << name.toStdString() << ">" << endl;

and it prints <>

Im using 4.2.2, suggestions?  Im mystified.

Jeff



--
 [ signature omitted ] 

Message 2 in thread

Jeff Lacki wrote:
> Im returning a QString from a class.  I return
> QString("") if the vector element isnt found.
> When I test for it on the return:
>
> name = getString();
> if (name.isEmpty())
> {
> 	error
> }
> else
> {
> 	do something
> }
>
> I always get the error condition.  I did a cout
> on the thing:
>
> cout << "<" << name.toStdString() << ">" << endl;
>
> and it prints <>
>
> Im using 4.2.2, suggestions?  Im mystified.
>   

My suggestion is that the vector element was not found. Both  your if 
statement and cout seem to suggest the same thing.

--Dave

--
 [ signature omitted ] 

Message 3 in thread

On 06.02.07 14:26:41, Jeff Lacki wrote:
> Im returning a QString from a class.  I return
> QString("") if the vector element isnt found.
> When I test for it on the return:
> 
> name = getString();
> if (name.isEmpty())
> {
> 	error
> }
> else
> {
> 	do something
> }
> 
> I always get the error condition.  I did a cout
> on the thing:
> 
> cout << "<" << name.toStdString() << ">" << endl;
> 
> and it prints <>

Uhm, and what exactly is the problem? Of course QString("") is an empty
QString, thats even documented. I don't see the problem.

Andreas

-- 
 [ signature omitted ] 

Message 4 in thread

Ugh, sorry for the waste of bandwidth. my mind reversed
the logic I was looking at.  I hate it when that happens.

Jeff

--
 [ signature omitted ]