[Development] QString behavior change
Gerhard Scheikl
g.scheikl at avibit.com
Thu Jul 30 09:38:12 CEST 2015
Hi
The behavior of QString::trimmed has changed from 5.3.2 to 5.5.
.trimmed() on an empty string (" ") makes it null
.trimmed() on an empty string ("") doesn't make it null
Is this intended or a bug?
By the way: the output of qDebug is not as expected:
there are additional whitespaces before true/false and there is even
another one before null at the first "Before trim" output.
Thanks
Best regards
Gerhard
qDebug() << "String with space";
QString my_string(" ");
qDebug() << "Before trim: empty:" << my_string.isEmpty() << " null:" << my_string.isNull();
my_string = my_string.trimmed();
qDebug() << "After trim: empty:" << my_string.isEmpty() << " null:" << my_string.isNull();
qDebug() << "\nEmpty string";
my_string = "";
qDebug() << "Before trim: empty:" << my_string.isEmpty() << " null:" << my_string.isNull();
my_string = my_string.trimmed();
qDebug() << "After trim: empty:" << my_string.isEmpty() << " null:" << my_string.isNull();
Output:
String with space
Before trim: empty: false null: false
After trim: empty: true null: true
Empty string
Before trim: empty: true null: false
After trim: empty: true null: false
More information about the Development
mailing list