View Full Version : QString problem
vermarajeev
25th October 2006, 15:51
Hi guys, this is something which is making me wild...
This is a simple thing but I'm not able to understand why this is not happening...
My code is something like this
const std::string &str = "hello";
QString s(str); //here is the error, cannot typecast std::string to QString
I dont want to use const char* in QString constructor
like this QString s(str.data());
My target is to use only std::string as an argument to QString...
Can anyone help please
Thankx
spud
25th October 2006, 15:53
try QString::fromStdString(str)
btw I am surprised this line doesn't crash the application:
const std::string &str = "hello";
vermarajeev
25th October 2006, 15:59
try QString::fromStdString(str)
btw I am surprised this line doesn't crash the application:
const std::string &str = "hello";
Hi thankx for your reply.
But I dont see any QString::fromStdString in Qt3.3.5...
Please help me
spud
25th October 2006, 16:05
I don't see why the following shouldn't work.
std::string str = "hello";
QString s(str);
Mind the missing '&'
vermarajeev
25th October 2006, 16:13
I don't see why the following shouldn't work.
std::string str = "hello";
QString s(str);
Mind the missing '&'
Sorry that too doesnt work...Have you tried on your system...
I get his error on my system.
cannot typecast std::string to QString
Thankx
vermarajeev
26th October 2006, 04:52
Hi guys, come on
this is a simple problem....
Please get me some ideas
Thankx
munna
26th October 2006, 05:00
try
std::string str = "hello";
QString s = str;
It works
munna
26th October 2006, 05:05
I am using 3.3.6 and the following code is not giving any error
std::string str = "hello";
QString s(str);
vermarajeev
26th October 2006, 13:43
I am using 3.3.6 and the following code is not giving any error
std::string str = "hello";
QString s(str);
This is really surprising, when I run this same code in Qt3.3.5, it works fine but when the same code is run in Qt3.3.4 it fails..Telling it cannot be typecasted.
How is that possible???Also when I just refered Qt3.3.4 assistant there is a member called
QString ( const std::string & str )
Then what is the problem? Is this a bug in Qt3.3.4?
I'm unable to understand..Please help me.
Cannot I make this run on Qt3.3.4??
Thankx
jacek
26th October 2006, 19:10
when I run this same code in Qt3.3.5, it works fine but when the same code is run in Qt3.3.4 it fails
Maybe that Qt 3.3.4 version was compiled without STL support?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.