Code doesnt work
Hellow, plaease, tell me why my code doesnt work?
- bool isClass = false;
- for(int a=0;a<=needNext.count();a++)
- {
- {
- isClass=true;
- a=needNext.count();
- }
- else
- {
- a=needNext.count();
- }
- }
It is must find last symbol in text unequal “ “(space) and if last symbol equal “{” should happen assignment
It is always display “2 (without second qoute)
As the text is supplied text
- background-color: #123123;
- }
for example
5 replies
There is an ambiguous ‘else’ here. put contents of every if in {} always. also you don’t need to convert QChar s to QString . they are themselves comparable.
I assume needNext is a QString (is not?)
try tis code:
- for(int a=0; a<=needNext.count(); a++)
- {
- {
- {
- qDebug() <<"1"+ needNext[a];
- isClass=true;
- // a=needNext.count();
- // probably you mean:
- break;
- }
- else
- {
- //a=needNext.count();
- break;
- qDebug() <<"2"+ needNext[a];
- }
- }
- }
If you want to iterate over all characters of a QString, you may want to use a bit more elegant way using iterators:
You must log in to post a reply. Not a member yet? Register here!

