QTextStream and unget (or ungetChar)



  • Hi,

    is unget possible with QTextStream?
    How does one go about peek'ing or unget'ing stuff?

    Use-case: read either a string of a number from a steam.
    How: read a character (is >> ws >> ch) and if it is a number (i.e. isdigit(ch) == true), unget it and read into an int (is >> number)

    Possible?
    Thanks.



  • Something like this might work (didn't try it)

    @
    qint64 text_pos;
    text_pos = text_stream.pos();

    // read char

    if(want_to_undo)
    {
    text_stream.seek(text_pos);
    // read number instead
    }

    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.