Qt ide gives error about"error: passing 'const QChar' as 'this' argument of 'QChar& QChar::operator=(const QChar&)' discards qualifiers"

for(int i=reqposition;;i++)

temp.at(j)=data.at(i);  // ERROR IS HERE

what do i do to solve it!

Recommended Answers

All 2 Replies

If you look at the documentation for QString here you can see that QString::at is declared as:

const QChar QString::at ( int position ) const

As you can see, the at member returns a QChar by value, which means you can use this method to see the value of a a character, but not to set the value. This is in contrast to the behaviour of the at member of std::string , which returns by reference and is overloaded with const and non-const versions. See here and compare with the QString version.

@ Ravenous thanks alot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.