Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

const char* to String object

Status
Not open for further replies.

Kojo105

Programmer
Jun 3, 2003
6
0
0
GB
I am using the QT Library for a project and I want to convert a const char* into a QString object. Is this possible?
 
Doesn't look like anyone is familiar with this "QT" library. Give us some more information about it. Does it have any documentation, help?

-pete
 
The QT library is similar to Motif in that it is a toolkit used mainly to give platform independence to GUI applications.
 
Perhaps this is a silly question, but have you tried this?

Code:
QString str( "Hello" );


Most worthwhile string classes provide a constructor based on const char*.
 
Yes, QString(const char*) constructor can do it. Moreover, class QString includes "hidden" constructors like (static) member functions QString QString::fromLatin1(const char*,xxx) and QString QString::fromLocal8Bit(const char*,xxx). Main constructor may be "disabled" with QT_NO_CAST_ASCII macros in the application (check it), but fromXX members will be active as ever. Read excellent Trolltech ( Qt Toolkit documentation...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top