QString userentry = ui->lineEdit->text();.
Now i need to loop through each character of the string and find the a matching charecter "A"
for(i=0;i<=20;i++)
{
if( userentry[i] == 'A' )
.............
}
I am getting error
QString userentry = ui->lineEdit->text();.
Now i need to loop through each character of the string and find the a matching charecter "A"
for(i=0;i<=20;i++)
{
if( userentry[i] == 'A' )
.............
}
I am getting error
What error do you get? use userentry.length() instead of fixed integer. See also QString::indexOf().
askbapi (31st March 2010)
how can I get each character of Qsrting?
Native C++ style:
---------------------------------------------------
char userenter[30]; int i;
userenter[]="god is great";
for(i=0; i<= 29; i++)
{
cout << userenter[i] << endl;
}
how to do it with QString?
Qt Code:
for (int i = 0; i < str.length(); ++i) qWarning() << str.at(i); // or str[i]To copy to clipboard, switch view to plain text mode
askbapi (31st March 2010)
You can also use QString::indexOf , cant you![]()
askbapi (31st March 2010)
Qt Code:
QString userenter; userenter ="god is great"; for(int i=0; i<= userenter.size(); i++) { cout << userenter[i] << endl; }To copy to clipboard, switch view to plain text mode
By the way, your code is incorrect.
askbapi (31st March 2010)
Thanks for your valuable reply!
It is clear.
Bookmarks