2008/9/9 Chris Cannam <[EMAIL PROTECTED]>:
>
>> Now ... .toStdString() does not work here.
>> ("error: 'const class QString' has no member named 'toStdString'")
>
> It's a pity, because toStdString is the obvious best function for many
> situations and I use it in all my other Qt4 code. I've never had a
> problem with it in the past (and fwiw, I use the Ubuntu packaged Qt4
> normally). However, if it doesn't work for you and it isn't obvious
> to you why not, then I guess it won't be obvious to other people
> either, so perhaps we should avoid it.
>
Found by googling the STL-error:
------------------------------------------------
"this happens ONLY if you're using
a different STL version, other than the one used when Qt was
compiled.. "
"
Using different STL versions is a major NO NO....
Even assigned an optimized version of a STL string to a Debug version
can (and often does) cause problems.
STL has no interface/implementation separation... There is no .lib to
get linked in. Everything is in the header. This is by design.
"
" It is a bug in QT. definitely not in his
code and using the same STL will make us more it more confusing because
I didn't see any STL version info in the QT docs.
basically the toStdString() function is not very nice and you should
avoid it... unless you're willing to wait for a QT release for every STL
release and make sure they're the same which seem to be impossible to
me. and what about using other compilers that are compatible with
general libs that has different stl implementation ?
"
"this be a problem of mixing debug and release versions"
"Brian Hahn" suggested this operator code:
"
#include <QString>
#include <ostream>
#include <string>
std::string& operator += ( std::string& _Std, const QString& _QStr )
{
return _Std += _QStr.toLocal8Bit().data();
}
std::ostream& operator << ( std::ostream& _Stream, const QString& _QStr )
{
_Stream << _QStr.toLocal8Bit().data();
return _Stream;
}
-- usage -
QString QStr = "Hello world";
std::string String;
String += QStr;
std::stringstream Stream;
Stream << QStr;
--------------
unfortunately you cannot overload the assignment operator =() without
modifying the QString class itself, which I do not recommend.
"
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel