PDA

View Full Version : QString == Operator


ToddAtWSU
27th December 2006, 17:43
I am trying to compare 2 QStrings with the == operator and I get some errors. My code looks like:

// line is a QString created earlier in the code.
QStringList confList = QStringList::split( QString( "=" ), line );
if( confList.at( 0 ) == QString( "LAST_OPEN_DIR" ) )
{
// Some code
}

My code errors out in the if-statement and here is the error I get.

error: no match for 'operator ==' in QValueList<T>::at( size_t) [with T = QString](0ul) == QString(((const char*)"LAST_OPEN_DIR"))'

Any idea how to fix this error. This is in Qt 3.3.3. Thanks!

ggrinder
27th December 2006, 18:08
According to the documentation of QValueList, the "at" method returns an iterator to the item at a given index. So:

if( *(confList.at( 0 )) == QString( "LAST_OPEN_DIR" ) )

should be correct.