⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qtextformat.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    \value UserProperty*//*!    \enum QTextFormat::ObjectTypes    \value NoObject    \value ImageObject    \value TableObject    \value UserObject The first object that can be used for application-specific purposes.*//*!    \enum QTextFormat::PageBreakFlag    \since 4.2    \value PageBreak_Auto The page break is determined automatically depending on the                          available space on the current page    \value PageBreak_AlwaysBefore The page is always broken before the paragraph/table    \value PageBreak_AlwaysAfter  A new page is always started after the paragraph/table*//*!    \fn bool QTextFormat::isValid() const    Returns true if the format is valid (i.e. is not    InvalidFormat); otherwise returns false.*//*!    \fn bool QTextFormat::isCharFormat() const    Returns true if this text format is a \c CharFormat; otherwise    returns false.*//*!    \fn bool QTextFormat::isBlockFormat() const    Returns true if this text format is a \c BlockFormat; otherwise    returns false.*//*!    \fn bool QTextFormat::isListFormat() const    Returns true if this text format is a \c ListFormat; otherwise    returns false.*//*!    \fn bool QTextFormat::isTableFormat() const    Returns true if this text format is a \c TableFormat; otherwise    returns false.*//*!    \fn bool QTextFormat::isFrameFormat() const    Returns true if this text format is a \c FrameFormat; otherwise    returns false.*//*!    \fn bool QTextFormat::isImageFormat() const    Returns true if this text format is an image format; otherwise    returns false.*//*!    Creates a new text format with an \c InvalidFormat.    \sa FormatType*/QTextFormat::QTextFormat()    : format_type(InvalidFormat){}/*!    Creates a new text format of the given \a type.    \sa FormatType*/QTextFormat::QTextFormat(int type)    : format_type(type){}/*!    \fn QTextFormat::QTextFormat(const QTextFormat &other)    Creates a new text format with the same attributes as the \a other    text format.*/QTextFormat::QTextFormat(const QTextFormat &rhs)    : d(rhs.d), format_type(rhs.format_type){}/*!    \fn QTextFormat &QTextFormat::operator=(const QTextFormat &other)    Assigns the \a other text format to this text format, and returns a    reference to this text format.*/QTextFormat &QTextFormat::operator=(const QTextFormat &rhs){    d = rhs.d;    format_type = rhs.format_type;    return *this;}/*!    Destroys this text format.*/QTextFormat::~QTextFormat(){}/*!   Returns the text format as a QVariant*/QTextFormat::operator QVariant() const{    return QVariant(QVariant::TextFormat, this);}/*!    Merges the \a other format with this format; where there are    conflicts the \a other format takes precedence.*/void QTextFormat::merge(const QTextFormat &other){    if (format_type != other.format_type)        return;    if (!d) {        d = other.d;        return;    }    if (!other.d)        return;    QTextFormatPrivate *d = this->d;    const QVector<QTextFormatPrivate::Property> &otherProps = other.d->props;    d->props.reserve(d->props.size() + otherProps.size());    for (int i = 0; i < otherProps.count(); ++i) {        const QTextFormatPrivate::Property &p = otherProps.at(i);        d->insertProperty(p.key, p.value);    }}/*!    Returns the type of this format.    \sa ObjectTypes*/int QTextFormat::type() const{    return format_type;}/*!    Returns this format as a block format.*/QTextBlockFormat QTextFormat::toBlockFormat() const{    QTextBlockFormat f;    f.QTextFormat::operator=(*this);    return f;}/*!    Returns this format as a character format.*/QTextCharFormat QTextFormat::toCharFormat() const{    QTextCharFormat f;    f.QTextFormat::operator=(*this);    return f;}/*!    Returns this format as a list format.*/QTextListFormat QTextFormat::toListFormat() const{    QTextListFormat f;    f.QTextFormat::operator=(*this);    return f;}/*!    Returns this format as a table format.*/QTextTableFormat QTextFormat::toTableFormat() const{    QTextTableFormat f;    f.QTextFormat::operator=(*this);    return f;}/*!    Returns this format as a frame format.*/QTextFrameFormat QTextFormat::toFrameFormat() const{    QTextFrameFormat f;    f.QTextFormat::operator=(*this);    return f;}/*!    Returns this format as an image format.*/QTextImageFormat QTextFormat::toImageFormat() const{    QTextImageFormat f;    f.QTextFormat::operator=(*this);    return f;}/*!    Returns the value of the property specified by \a propertyId. If the    property isn't of QTextFormat::Bool type, false is returned instead.    \sa setProperty() intProperty() doubleProperty() stringProperty() colorProperty() lengthProperty() lengthVectorProperty() Property*/bool QTextFormat::boolProperty(int propertyId) const{    if (!d)        return false;    const QVariant prop = d->property(propertyId);    if (prop.type() != QVariant::Bool)        return false;    return prop.toBool();}/*!    Returns the value of the property specified by \a propertyId. If the    property is not of QTextFormat::Integer type, 0 is returned instead.    \sa setProperty() boolProperty() doubleProperty() stringProperty() colorProperty() lengthProperty() lengthVectorProperty() Property*/int QTextFormat::intProperty(int propertyId) const{    if (!d)        return 0;    const QVariant prop = d->property(propertyId);    if (prop.type() != QVariant::Int)        return 0;    return prop.toInt();}/*!    Returns the value of the property specified by \a propertyId. If the    property isn't of QVariant::Double type, 0 is returned instead.    \sa setProperty() boolProperty() intProperty() stringProperty() colorProperty() lengthProperty() lengthVectorProperty() Property*/qreal QTextFormat::doubleProperty(int propertyId) const{    if (!d)        return 0.;    const QVariant prop = d->property(propertyId);    if (prop.type() != QVariant::Double)        return 0.;    return prop.toDouble(); // ####}/*!    Returns the value of the property given by \a propertyId; if the    property isn't of QVariant::String type, an empty string is    returned instead.    \sa setProperty() boolProperty() intProperty() doubleProperty() colorProperty() lengthProperty() lengthVectorProperty() Property*/QString QTextFormat::stringProperty(int propertyId) const{    if (!d)        return QString();    const QVariant prop = d->property(propertyId);    if (prop.type() != QVariant::String)        return QString();    return prop.toString();}/*!    Returns the value of the property given by \a propertyId; if the    property isn't of QVariant::Color type, an invalid color is    returned instead.    \sa setProperty(), boolProperty(), intProperty(), doubleProperty(),        stringProperty(), lengthProperty(), lengthVectorProperty(), Property*/QColor QTextFormat::colorProperty(int propertyId) const{    if (!d)        return QColor();    const QVariant prop = d->property(propertyId);    if (prop.type() != QVariant::Color)        return QColor();    return qvariant_cast<QColor>(prop);}/*!    Returns the value of the property given by \a propertyId; if the    property isn't of QVariant::Pen type, Qt::NoPen is    returned instead.    \sa setProperty() boolProperty() intProperty() doubleProperty() stringProperty() lengthProperty() lengthVectorProperty() Property*/QPen QTextFormat::penProperty(int propertyId) const{    if (!d)        return QPen(Qt::NoPen);    const QVariant prop = d->property(propertyId);    if (prop.type() != QVariant::Pen)        return QPen(Qt::NoPen);    return qvariant_cast<QPen>(prop);}/*!    Returns the value of the property given by \a propertyId; if the    property isn't of QVariant::Brush type, Qt::NoBrush is    returned instead.    \sa setProperty() boolProperty() intProperty() doubleProperty() stringProperty() lengthProperty() lengthVectorProperty() Property*/QBrush QTextFormat::brushProperty(int propertyId) const{    if (!d)        return QBrush(Qt::NoBrush);    const QVariant prop = d->property(propertyId);    if (prop.type() != QVariant::Brush)        return QBrush(Qt::NoBrush);    return qvariant_cast<QBrush>(prop);}/*!    Returns the value of the property given by \a propertyId.    \sa setProperty() boolProperty() intProperty() doubleProperty() stringProperty() colorProperty() lengthVectorProperty() Property*/QTextLength QTextFormat::lengthProperty(int propertyId) const{    if (!d)        return QTextLength();    return qvariant_cast<QTextLength>(d->property(propertyId));}/*!    Returns the value of the property given by \a propertyId. If the    property isn't of QTextFormat::LengthVector type, an empty length    vector is returned instead.    \sa setProperty() boolProperty() intProperty() doubleProperty() stringProperty() colorProperty() lengthProperty() Property*/QVector<QTextLength> QTextFormat::lengthVectorProperty(int propertyId) const{    QVector<QTextLength> vector;    if (!d)        return vector;    const QVariant prop = d->property(propertyId);    if (prop.type() != QVariant::List)        return vector;    QList<QVariant> propertyList = prop.toList();    for (int i=0; i<propertyList.size(); ++i) {        QVariant var = propertyList.at(i);        if (var.type() == QVariant::TextLength)            vector.append(qvariant_cast<QTextLength>(var));    }    return vector;}/*!    Returns the property specified by the given \a propertyId.*/QVariant QTextFormat::property(int propertyId) const{    return d ? d->property(propertyId) : QVariant();}/*!    Sets the property specified by the \a propertyId to the given \a value.*/void QTextFormat::setProperty(int propertyId, const QVariant &value){    if (!d)        d = new QTextFormatPrivate;    if (!value.isValid())        clearProperty(propertyId);    else        d->insertProperty(propertyId, value);}/*!    Sets the value of the property given by \a propertyId to \a value.    \sa lengthVectorProperty() Property*/void QTextFormat::setProperty(int propertyId, const QVector<QTextLength> &value){    if (!d)        d = new QTextFormatPrivate;    QVariantList list;    for (int i=0; i<value.size(); ++i)        list << value.at(i);    d->insertProperty(propertyId, list);}/*!  Clears the value of the property given by \a propertyId */void QTextFormat::clearProperty(int propertyId){    if (!d)        return;    d->clearProperty(propertyId);}/*!    \fn void QTextFormat::setObjectType(int type)    Sets the text format's object \a type. See \c{ObjectTypes}.*//*!    \fn int QTextFormat::objectType() const    Returns the text format's object type. See \c{ObjectTypes}.*//*!    Returns the index of the format object, or -1 if the format object is invalid.    \sa setObjectIndex()*/int QTextFormat::objectIndex() const{    if (!d)        return -1;    const QVariant prop = d->property(ObjectIndex);    if (prop.type() != QVariant::Int) // ####        return -1;    return prop.toInt();}/*!    \fn void QTextFormat::setObjectIndex(int index)    Sets the format object's object \a index.    \sa objectIndex()*/void QTextFormat::setObjectIndex(int o){    if (o == -1) {        if (d)            d->clearProperty(ObjectIndex);    } else {        if (!d)            d = new QTextFormatPrivate;        // ### type        d->insertProperty(ObjectIndex, o);    }}/*!    Returns true if the text format has a property with the given \a    propertyId; otherwise returns false.    \sa properties() Property*/bool QTextFormat::hasProperty(int propertyId) const{    return d ? d->hasProperty(propertyId) : false;}/*    Returns the property type for the given \a propertyId.    \sa hasProperty() allPropertyIds() Property*//*!    Returns a map with all properties of this text format.*/QMap<int, QVariant> QTextFormat::properties() const{    QMap<int, QVariant> map;    if (d) {        for (int i = 0; i < d->props.count(); ++i)            map.insert(d->props.at(i).key, d->props.at(i).value);    }    return map;}/*!    \since 4.3

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -