convert from irrlicht to qt

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
YankzzDev
Posts: 23
Joined: Wed Oct 05, 2011 4:37 am
Location: Indonesia

convert from irrlicht to qt

Post by YankzzDev »

hi all...

i try to make a qt project using irrlicht engine now

i want to ask about converting string from irrlicht to qt

if irrlicht declation string is like this :

Code: Select all

 
core::stringw MessageText;
MessageText = "Test Message";
 

and qt declation string is like this:

Code: Select all

 
QString str;
 
and i try to combine 2 string and i test it like that:

Code: Select all

 
str = MessageText;
 
but it's failed...

and got this error..

Error 41 error C2664: 'QLineEdit::setText' : cannot convert parameter 1 from 'irr::core::stringw' to 'const QString &'


any solution?

i am apologize if my question is very naive or other...

because i am a beginner...


Regard's


Yanto Chen
Nobody is Perfect!!
Josh1billion
Posts: 125
Joined: Thu Dec 11, 2008 9:50 pm
Location: Wisconsin
Contact:

Re: convert from irrlicht to qt

Post by Josh1billion »

I haven't used Qt before, but I would imagine you could do something like this:

Code: Select all

str = MessageText.c_str();
www.JoshForde.com

Latest release: Super Orbulite World.
In development: Season of Dreams and others
YankzzDev
Posts: 23
Joined: Wed Oct 05, 2011 4:37 am
Location: Indonesia

Re: convert from irrlicht to qt

Post by YankzzDev »

Josh1billion wrote:I haven't used Qt before, but I would imagine you could do something like this:

Code: Select all

str = MessageText.c_str();
it's failed and produced this error:

Error 41 error C3867: 'irr::core::string<T>::c_str': function call missing argument list; use '&irr::core::string<T>::c_str' to create a pointer to member
Nobody is Perfect!!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: convert from irrlicht to qt

Post by hybrid »

Are you sure that you did not forget the parantheses after c_str() <-- these ones?!
YankzzDev
Posts: 23
Joined: Wed Oct 05, 2011 4:37 am
Location: Indonesia

Re: convert from irrlicht to qt

Post by YankzzDev »

hybrid wrote:Are you sure that you did not forget the parantheses after c_str() <-- these ones?!
yeah, i try put it and produced this error:


Error 41 error C2440: '=' : cannot convert from 'const wchar_t *' to 'QString *'
Nobody is Perfect!!
CuteAlien
Admin
Posts: 9930
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: convert from irrlicht to qt

Post by CuteAlien »

It seems QString does not support wide-strings. They use some 8-bit unicode, so I guess it's UTF-8. The easy way is copying wide-char into char strings (for example with core::stringc(MessageText) - the stringc constructor will do that). The disadvantage is that this will not work with internationalization - meaning it only works if the wide-chars contain nothing but ascii. The clean way is doing a real conversion from wide-char to unicode, search here for the convert_utf files for a conversion doing that: http://www.michaelzeilfelder.de/irrlich ... tringTable
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
aanderse
Posts: 155
Joined: Sun Aug 10, 2008 2:02 pm
Location: Canada

Re: convert from irrlicht to qt

Post by aanderse »

YankzzDev wrote: i want to ask about converting string from irrlicht to qt
you are looking for this: http://doc.qt.nokia.com/4.7/qstring.html#fromWCharArray

you would use it like this:

Code: Select all

 
core::stringw s1 = L"my string!";
QString s2 = QString::fromWCharArray (s1.c_str ());
 
CuteAlien wrote:It seems QString does not support wide-strings. They use some 8-bit unicode, so I guess it's UTF-8.
hmm... not sure where you picked that up? QString is a fantastic string class and it certainly is NOT utf8 (though it can handle utf8)
The QString class provides a Unicode character string.
QString stores a string of 16-bit QChars, where each QChar corresponds one Unicode 4.0 character. (Unicode characters with code values above 65535 are stored using surrogate pairs, i.e., two consecutive QChars.)
please don't be shy to use the qt documentation, it is fantastic and full of great examples, tutorials, etc...
CuteAlien
Admin
Posts: 9930
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: convert from irrlicht to qt

Post by CuteAlien »

Oops, sorry I just did a quick-check this morning for the QString constructor and stopped reading after "char* Constructs a string initialized with the 8-bit string str. The given const char pointer is converted to Unicode using the fromAscii() function." Didn't see all the other constructors *shame*
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply