Why is QString(char*) private in trunk?
-
In qstring.h these methods are now private, I checked the qt5 trunk out from git:
private:
#if defined(QT_NO_CAST_FROM_ASCII)
QString &operator+=(const char *s);
QString &operator+=(const QByteArray &s);
QString(const char *ch);
QString(const QByteArray &a);
QString &operator=(const char *ch);
QString &operator=(const QByteArray &a);
#endifWhy? This is going to make a lot of code uglier, I now have to wrap every single function call where I used to be able to say "string.split("HI")" with "string.split(QString.fromUtf8("HI")"
-
Hi,
Look upper in the header file under the "// ASCII compatibility" comment, you'll see that if you don't define QT_NO_CAST_FROM_ASCII the methods are public.
As for the rest you would rather use:
@string.split(QLatin1String("Hi"));@
The reasoning behind is explained in the documentation of QString and QLatin1String
-
Hi, also you can use
@
string.split(tr("Hi"));
@it's useful in those environments where QString(char*) is private 100% of the time, for example when you're writing a Qt Creator plugin.
As SGaist suggests, it's a good idea always to put your hardcoded strings inside a function anyway, because maybe your product is a success and you have to translate it to another language!
-
There are different approaches to making something multilingual, in any case I would rather have the option of coding as fast as possible and worry about business decisions at a point of time of my choosing.