zoukankan      html  css  js  c++  java
  • QTextStream & QString 配合

    把QString视为一Stream使用。

    QTextStream的相关函数

    QTextStream ( QString * string, QIODevice::OpenMode openMode = QIODevice::ReadWrite )

    void setString ( QString * string, QIODevice::OpenMode openMode = QIODevice::ReadWrite )

    bool QTextStream::atEnd () const

    Returns true if there is no more data to be read from the QTextStream; otherwise returns false. This is similar to, but not the same as calling QIODevice::atEnd(), as QTextStream also takes into account its internal Unicode buffer.

    qint64 QTextStream::pos () const

    Returns the device position corresponding to the current position of the stream, or -1 if an error occurs (e.g., if there is no device or string, or if there's a device error).

    Because QTextStream is buffered, this function may have to seek the device to reconstruct a valid device position. This operation can be expensive, so you may want to avoid calling this function in a tight loop.

    bool QTextStream::seek ( qint64 pos )

    Seeks to the position pos in the device. Returns true on success; otherwise returns false.

    Status QTextStream::status () const

    Returns the status of the text stream.

    QTextStream::Ok
    0
    The text stream is operating normally.

    QTextStream::ReadPastEnd
    1
    The text stream has read past the end of the data in the underlying device.

    QTextStream::ReadCorruptData
    2
    The text stream has read corrupt data.

     

    QString的相关函数

     

    bool QString::isEmpty () const

    Returns true if the string has no characters; otherwise returns false.

    Example:

         QString().isEmpty();            // returns true
         QString("").isEmpty();          // returns true
         QString("x").isEmpty();         // returns false
         QString("abc").isEmpty();       // returns false
    bool QString::isNull () const

    Returns true if this string is null; otherwise returns false.

    Example:

         QString().isNull();             // returns true
         QString("").isNull();           // returns false
         QString("abc").isNull();        // returns false

    Qt makes a distinction between null strings and empty strings for historical reasons. For most applications, what matters is whether or not a string contains any data, and this can be determined using the isEmpty() function.

  • 相关阅读:
    互联网某些方面代替了朋友的作用
    穷人
    血脉之力
    鹤立鸡群
    如果有了一个进化的机会,你会选择放弃人类这个身份么?
    怎么样的制度才算是好制度
    /etc/fstab 参数详解及如何设置开机自动挂载
    Linux 查看系统硬件信息(实例详解)
    Linux下添加新硬盘,分区及挂载
    Quartz.NET
  • 原文地址:https://www.cnblogs.com/justin_s/p/1899557.html
Copyright © 2011-2022 走看看