Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to convert sf::String to QString and convert back?  (Read 2735 times)

0 Members and 1 Guest are viewing this topic.

ccleung6

  • Newbie
  • *
  • Posts: 22
    • View Profile
How to convert sf::String to QString and convert back?
« on: September 26, 2012, 07:55:44 am »
Hi all,

How to do the conversion between sf::String and QString?

Thanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: How to convert sf::String to QString and convert back?
« Reply #1 on: September 26, 2012, 08:20:17 am »
Look at the doc: there are only three functions that convert a sf::String to a common representation (std::string, std::wstring and UTF-32).

Now look at the documentation of QString: there are many functions that convert a regular string to a QString: fromStdString, fromStdWString.

So........ ;)
Laurent Gomila - SFML developer

ccleung6

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: How to convert sf::String to QString and convert back?
« Reply #2 on: September 30, 2012, 09:24:59 am »
Look at the doc: there are only three functions that convert a sf::String to a common representation (std::string, std::wstring and UTF-32).

Now look at the documentation of QString: there are many functions that convert a regular string to a QString: fromStdString, fromStdWString.

So........ ;)

QString::toStdWString() works for UTF-8 characters, it can feed into a sf::String and drawn.

Thanks.

 

anything