Results 1 to 2 of 2

Thread: QString - no member function called 'find'

  1. #1
    Join Date
    Jan 2009
    Posts
    3
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default QString - no member function called 'find'

    I wrote a function:

    Qt Code:
    1. #include<qstring.h>
    2.  
    3. void Calculator::calculation(QString &operation, QString &text_display)
    4. {
    5. QString a_string = "", b_string = "", result_string = "";
    6. double a, b, result;
    7. int position = 0, i, j;
    8.  
    9. while(1)
    10. {
    11. if ( ( position = operation.find('*') ) == -1 ) break;
    12.  
    13. for( i = position; i = 0 ; i-- )
    14. {
    15. if( operation.at( i ) == '*' || operation.at( i ) == '/' || operation.at( i ) == '+' || operation.at( i ) == '-' )
    16. break;
    17. a_string += operation.at( i );
    18. }
    19. for( j = position; j < operation.length() ; j++ )
    20. {
    21. if( operation.at( j ) == '*' || operation.at( j ) == '/' || operation.at( j ) == '+' || operation.at( j ) == '-' )
    22. break;
    23. b_string += operation.at( j );
    24. }
    25. a = a_string.toDouble();
    26. b = b_string.toDouble();
    27. result = a*b;
    28. result_string = result_string.setNum( result, 'f', 10 );
    29. operation.replace( i, i + j + 1, result_string );
    30. }
    31. text_display = result_string;
    32. ui.display->setText( text_display );
    33. }
    To copy to clipboard, switch view to plain text mode 

    Compiler says that QString class has no member function called 'find' (line 11), but when I read QString documentation...

    http://doc.trolltech.com/3.3/qstring.html#find

    ...it's right there. Every other function like lenght() or at() works. What's wrong then?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QString - no member function called 'find'

    It's from Qt3 and you are using Qt4. Use QString::indexOf().

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

    pitterb (13th January 2009)

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  3. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  4. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12: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.