Results 1 to 2 of 2

Thread: error 'class QCharRef'

  1. #1
    Join Date
    Jan 2006
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default error 'class QCharRef'

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error 'class QCharRef'

    Quote Originally Posted by fwohlfert
    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.