Results 1 to 5 of 5

Thread: QTextStream, doubles and ints

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTextStream, doubles and ints

    Thank's I thought of doing it that way.
    I just want to know if there are a way like int std c++ one can use std::stringstream and read it in the way I tried to with Qt.

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTextStream, doubles and ints

    Hi,

    Using QTextStream you can't because all is text, so then you have to parse the data.
    Òscar Llarch i Galán

  3. #3
    Join Date
    Mar 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTextStream, doubles and ints

    If one look at the example in the manual. I thought it would work that way.
    By default, when reading numbers from a stream of text, QTextStream will automatically detect the number's base representation. For example, if the number starts with "0x", it is assumed to be in hexadecimal form. If it starts with the digits 1-9, it is assumed to be in decimal form, and so on. You can set the integer base, thereby disabling the automatic detection, by calling setIntegerBase(). Example:
    QTextStream in("0x50 0x20");
    int firstNumber, secondNumber;

    in >> firstNumber; // firstNumber == 80
    in >> dec >> secondNumber; // secondNumber == 0

    char ch;
    in >> ch; // ch == 'x'

Similar Threads

  1. QTreeView questions about view doubles and more
    By davisjamesf in forum Qt Programming
    Replies: 1
    Last Post: 9th August 2007, 00:39

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
  •  
Qt is a trademark of The Qt Company.