Results 1 to 2 of 2

Thread: QString == Operator

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question QString == Operator

    I am trying to compare 2 QStrings with the == operator and I get some errors. My code looks like:

    Qt Code:
    1. // line is a QString created earlier in the code.
    2. QStringList confList = QStringList::split( QString( "=" ), line );
    3. if( confList.at( 0 ) == QString( "LAST_OPEN_DIR" ) )
    4. {
    5. // Some code
    6. }
    To copy to clipboard, switch view to plain text mode 

    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!

  2. #2
    Join Date
    Dec 2006
    Posts
    9
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QString == Operator

    According to the documentation of QValueList, the "at" method returns an iterator to the item at a given index. So:
    Qt Code:
    1. if( *(confList.at( 0 )) == QString( "LAST_OPEN_DIR" ) )
    To copy to clipboard, switch view to plain text mode 
    should be correct.

  3. The following user says thank you to ggrinder for this useful post:

    ToddAtWSU (3rd January 2007)

Similar Threads

  1. QString problem
    By vermarajeev in forum Qt Programming
    Replies: 9
    Last Post: 26th October 2006, 19:10
  2. Replies: 2
    Last Post: 12th October 2006, 09:17
  3. QSqlQueryModel + set Write
    By raphaelf in forum Qt Programming
    Replies: 7
    Last Post: 5th June 2006, 08:55
  4. Converting QString to unsigned char
    By salston in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 22:10
  5. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 14:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.