Results 1 to 2 of 2

Thread: trying to convert string to uppercase

  1. #1
    Join Date
    Jun 2017
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default trying to convert string to uppercase

    Can anyone please help where did I make mistake please?


    void Registr(QString str)
    {
    QString rezult = str;
    for(int i = 0; i < str.size(); i++)
    {
    rezult[i] = toUpper(str[i]);
    }
    QMessageBox msg;
    msg.setText(rezult);
    msg.exec();
    }

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: trying to convert string to uppercase

    toUpper() is a member function of QString class, you will have to call it on the QString object.
    Qt Code:
    1. void Registr(QString str)
    2. {
    3. msg.setText(str.toUpper());
    4. msg.exec();
    5. }
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. How to convert from QString to string ?
    By probine in forum Newbie
    Replies: 2
    Last Post: 1st December 2010, 02:50
  2. How to convert string into const int ?
    By babygal in forum Qt Programming
    Replies: 3
    Last Post: 16th July 2010, 11:57
  3. How to convert QString to std::string or char*?
    By yangyunzhao in forum Qt Programming
    Replies: 26
    Last Post: 26th August 2009, 07:52
  4. convert a string to hex
    By priceey in forum Qt Programming
    Replies: 7
    Last Post: 12th February 2009, 11:38
  5. Convert from QByteArray to String ?
    By probine in forum Newbie
    Replies: 3
    Last Post: 25th March 2006, 16:49

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.