Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextStream and unget (or ungetChar)
Forum Updated to NodeBB v4.3 + New Features

QTextStream and unget (or ungetChar)

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 881 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nicesw123
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rondog
      wrote on last edited by
      #2

      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
      }

      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved