Solved Incrementing String value
-
Well this is my JSON value
"INKA010101002020"
which is in QByteArray, where I've converted it to QString for substring of last 3 digits "020" then I need to add 1 (auto increment +1) to that 3 digit one, where I've converted it to 'int' but didn't work so any suggestions ?? -
@Vineela Something like
QString str = "INKA010101002020"; QString subStr = str.right(3); int number = subStr.toInt(); ++number; str = str.chopped(3) + QString("%1").arg(number, 3, 10, '0');
-
@jsulm well this was my answer
INKA01010100221.000000000000000000000000000000000000000000000000
I wanted 021 only the last three digits to get added -
@Vineela no its not
show us what you're actually doing.
-
-
@J.Hilk oh yes it worked not added QChar at last thanks.
-
-
@Vineela And what is the problem? You can append a string easily to another one...
-
@jsulm oh yes ive tried that i got INKA010101001\u0001 this
I've used this codeQString dd= store; dd.append(001);
-
-
//String concatenation QString a("123"); QString b("001"); int num =1; QString c = a + b == a.append(b) == a + QString::number(num).rightJustified(3,QChar('0'));
-
-
please mark the topic as solved
-
This post is deleted!