PDA

View Full Version : error 'class QCharRef'



fwohlfert
24th January 2006, 21:54
I am using what I think is a QString but I am getting an error that I cant find in the doc.


QString s = query.value(0).toString;
when I try to reference s like
convrt[c_idx] = s[s_idx].toInt

I get an error that 'class QCharRef' has no member named 'toInt'

I have been seaching the doc for class QCharRef and I have not found it,
anyone point me in the right direction.

Thanks in advance

jacek
24th January 2006, 22:08
I have been seaching the doc for class QCharRef and I have not found it, anyone point me in the right direction.
It's documented in a bit unusual way:
QCharRef QString::operator[] ( int i )
Returns the character at index position i as a modifiable reference.
Example:
if (str[0] == QChar('?'))
str[0] = QChar('_');
The return value is of type QCharRef, a helper class for QString. When you get an object of type QCharRef, you can use it as if it were a QChar &. If you assign to it, the assignment will apply to the character in the QString from which you got the reference.

The problem is that QChar has no method called toInt(), try QChar::unicode() instead.