How can you cut a string up to a certain number character C++ QT
-
wrote on 2 Nov 2022, 06:50 last edited by
if my QT doesnt know the function sliced()
for example I have this string:
"gt200"
and I want to get the string 200 and to cast it to int.
and always the string before the int its 2 letters.
how can I do it without sliced()? -
wrote on 2 Nov 2022, 07:46 last edited by
Yes you will get yy=300.
Just try the code yourself :) -
wrote on 2 Nov 2022, 07:17 last edited by
use
QString::mid()
-
wrote on 2 Nov 2022, 07:37 last edited by Bonnie 11 Feb 2022, 07:41
You ask for something equivalent to
slice()
(in javascript right?), that's it. It doesn't care the characters are numbers or not.
mid(2)
will just get you a substring from index 2 to the end of the string.
And Qt hasQString::toInt()
,QString::toUInt()
,QString::toLong()
, etc.. -
You ask for something equivalent to
slice()
(in javascript right?), that's it. It doesn't care the characters are numbers or not.
mid(2)
will just get you a substring from index 2 to the end of the string.
And Qt hasQString::toInt()
,QString::toUInt()
,QString::toLong()
, etc.. -
wrote on 2 Nov 2022, 07:46 last edited by
Yes you will get yy=300.
Just try the code yourself :)
1/7