114#ifndef QT_NO_DATASTREAM
123 double fixedValueOrPercentage;
125 length.fixedValueOrPercentage = fixedValueOrPercentage;
171 for (
int i = 0;
i <
props.size(); ++
i)
181 for (
int i = 0;
i <
props.size(); ++
i)
193 for (
int i = 0;
i <
props.size(); ++
i)
204 return props.at(idx).value;
221 size_t recalcHash()
const;
222 void recalcFont()
const;
224 mutable bool hashDirty;
225 mutable bool fontDirty;
226 mutable size_t hashValue;
235 return (
color.isValid()) ?
color.rgba() : 0x234109;
254 case QMetaType::Int:
return 0x811890U +
variant.
toInt();
255 case QMetaType::QBrush:
256 return 0x01010101 +
hash(qvariant_cast<QBrush>(
variant));
258 case QMetaType::QPen:
return 0x02020202 +
hash(qvariant_cast<QPen>(
variant));
259 case QMetaType::QVariantList:
260 return 0x8377U + qvariant_cast<QVariantList>(
variant).size();
261 case QMetaType::QColor:
return hash(qvariant_cast<QColor>(
variant));
262 case QMetaType::QTextLength:
263 return 0x377 +
hash(qvariant_cast<QTextLength>(
variant).rawValue());
273 return (
d ?
d->hash() : 0) +
format;
276size_t QTextFormatPrivate::recalcHash()
const
292 fnt = fnt.
resolve(defaultFont);
301 qreal pixelSize = scaleFactors[htmlFontSize] * defaultFont.
pixelSize();
304 qreal pointSize = scaleFactors[htmlFontSize] * defaultFont.
pointSizeF();
312void QTextFormatPrivate::recalcFont()
const
317 bool hasSpacingInformation =
false;
319 qreal letterSpacing = 0.0;
321 for (
int i = 0;
i <
props.size(); ++
i) {
322 switch (
props.at(
i).key) {
327 f.setStyleName(
props.at(
i).value.toString());
330 f.setPointSizeF(
props.at(
i).value.toReal());
333 f.setPixelSize(
props.at(
i).value.toInt());
337 int weight = weightValue.toInt();
338 if (
weight >= 0 && weightValue.isValid())
342 f.setItalic(
props.at(
i).value.toBool());
346 f.setUnderline(
props.at(
i).value.toBool());
352 f.setOverline(
props.at(
i).value.toBool());
355 f.setStrikeOut(
props.at(
i).value.toBool());
359 hasSpacingInformation =
true;
362 letterSpacing =
props.at(
i).value.toReal();
363 hasSpacingInformation =
true;
366 f.setWordSpacing(
props.at(
i).value.toReal());
373 if (
f.fixedPitch() !=
value)
377 f.setStretch(
props.at(
i).value.toInt());
389 f.setKerning(
props.at(
i).value.toBool());
396 if (hasSpacingInformation)
397 f.setLetterSpacing(spacingType, letterSpacing);
403#ifndef QT_NO_DATASTREAM
407 if (
stream.version() < QDataStream::Qt_6_0) {
458 fmt.d->insertProperty(
key,
it.value());
466 return stream << static_cast<const QTextFormat &>(
fmt);
476 return stream << static_cast<const QTextFormat &>(
fmt);
486 return stream << static_cast<const QTextFormat &>(
fmt);
496 return stream << static_cast<const QTextFormat &>(
fmt);
506 return stream << static_cast<const QTextFormat &>(
fmt);
873 : format_type(InvalidFormat)
895 :
d(rhs.
d), format_type(rhs.format_type)
908 format_type = rhs.format_type;
942 if (format_type !=
other.format_type)
956 p->props.reserve(
p->props.size() + otherProps.size());
957 for (
int i = 0;
i < otherProps.size(); ++
i) {
958 const QT_PREPEND_NAMESPACE(
Property) &prop = otherProps.at(
i);
959 if (prop.value.isValid()) {
960 p->insertProperty(prop.key, prop.value);
962 p->clearProperty(prop.key);
1047 if (prop.
userType() != QMetaType::Bool)
1067 if (prop.
userType() != QMetaType::Int)
1069 return prop.
toInt();
1085 if (prop.
userType() != QMetaType::Double && prop.
userType() != QMetaType::Float)
1087 return qvariant_cast<qreal>(prop);
1103 if (prop.
userType() != QMetaType::QString)
1121 if (prop.
userType() != QMetaType::QColor)
1123 return qvariant_cast<QColor>(prop);
1139 if (prop.
userType() != QMetaType::QPen)
1141 return qvariant_cast<QPen>(prop);
1157 if (prop.
userType() != QMetaType::QBrush)
1159 return qvariant_cast<QBrush>(prop);
1172 return qvariant_cast<QTextLength>(d->
property(propertyId));
1185 QList<QTextLength>
list;
1189 if (prop.
userType() != QMetaType::QVariantList)
1192 const QList<QVariant> propertyList = prop.
toList();
1193 for (
const auto &
var : propertyList) {
1236 for (
int i = 0;
i < numValues; ++
i)
1282 if (prop.
userType() != QMetaType::Int)
1284 return prop.
toInt();
1329 QMap<int, QVariant>
map;
1362 if (format_type != rhs.format_type)
1377 return *d == *rhs.d;
1506#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
1539#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
1990 if (prop.
userType() == QMetaType::QStringList)
1992 else if (prop.
userType() != QMetaType::QString)
2109 if (pointSize > 0) {
2155 return d ?
d->font() :
QFont();
2244 QList<QVariant>
list;
2246 for (
const auto &e : tabs)
2261 return QList<QTextOption::Tab>();
2262 QList<QTextOption::Tab> answer;
2263 const QList<QVariant> variantsList = qvariant_cast<QList<QVariant> >(
variant);
2264 answer.reserve(variantsList.size());
2265 for (
const auto &e: variantsList)
2266 answer.append(qvariant_cast<QTextOption::Tab>(e));
4035 if (idx < 0 || idx >=
formats.size())
4046 formats[
i].d->resolveFont(defaultFnt);
4049#ifndef QT_NO_DEBUG_STREAM
4053 dbg.nospace() <<
"QTextLength(QTextLength::Type(" << l.
type() <<
"))";
4060 dbg.nospace() <<
"QTextFormat(QTextFormat::FormatType(" <<
f.type() <<
"))";
4068#include "moc_qtextformat.cpp"
The QColor class provides colors based on RGB, HSV or CMYK values.
\inmodule QtCore\reentrant
StyleHint
Style hints are used by the \l{QFont}{font matching} algorithm to find an appropriate default family ...
StyleStrategy styleStrategy() const
Returns the StyleStrategy.
QString styleName() const
int pixelSize() const
Returns the pixel size of the font if it was set with setPixelSize().
StyleHint styleHint() const
Returns the StyleHint.
bool strikeOut() const
Returns true if strikeout has been set; otherwise returns false.
bool underline() const
Returns true if underline has been set; otherwise returns false.
void setFamilies(const QStringList &)
qreal letterSpacing() const
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
HintingPreference hintingPreference() const
Capitalization capitalization() const
QStringList families() const
Weight weight() const
Returns the weight of the font, using the same scale as the \l{QFont::Weight} enumeration.
@ HintingPreferenceResolved
qreal wordSpacing() const
int pointSize() const
Returns the point size of the font.
int stretch() const
Returns the stretch factor for the font.
bool kerning() const
Returns true if kerning should be used when drawing text with this font.
void setPixelSize(int)
Sets the font size to pixelSize pixels, with a maxiumum size of an unsigned 16-bit integer.
bool fixedPitch() const
Returns true if fixed pitch has been set; otherwise returns false.
void setResolveMask(uint mask)
qreal pointSizeF() const
Returns the point size of the font.
SpacingType letterSpacingType() const
Style style() const
Returns the style of the font.
StyleStrategy
The style strategy tells the \l{QFont}{font matching} algorithm what type of fonts should be used to ...
void setPointSizeF(qreal)
Sets the point size to pointSize.
Weight
Qt uses a weighting scale from 1 to 1000 compatible with OpenType.
bool overline() const
Returns true if overline has been set; otherwise returns false.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
iterator insert(const Key &key, const T &value)
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
const_iterator constFind(const Key &key) const noexcept
qreal widthF() const
Returns the pen width with floating point precision.
QColor color() const
Returns the color of this pen's brush.
const_iterator constBegin() const noexcept
const T * constData() const noexcept
Returns a const pointer to the shared data object.
T * data()
Returns a pointer to the shared data object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QList< QTextOption::Tab > tabPositions() const
QTextBlockFormat()
Constructs a new QTextBlockFormat.
void setTabPositions(const QList< QTextOption::Tab > &tabs)
FontPropertiesInheritanceBehavior
QStringList anchorNames() const
void setFontFamilies(const QStringList &families)
void setUnderlineStyle(UnderlineStyle style)
UnderlineStyle underlineStyle() const
void setFontWordSpacing(qreal spacing)
QTextCharFormat()
Constructs a new character format object.
void setFontPointSize(qreal size)
Sets the text format's font size.
UnderlineStyle
This enum describes the different ways drawing underlined text.
QFont font() const
Returns the font for this character format.
void setFontKerning(bool enable)
void setFontStyleHint(QFont::StyleHint hint, QFont::StyleStrategy strategy=QFont::PreferDefault)
void setFontFixedPitch(bool fixedPitch)
If fixedPitch is true, sets the text format's font to be fixed pitch; otherwise a non-fixed pitch fon...
void setFontLetterSpacing(qreal spacing)
void setFontStyleStrategy(QFont::StyleStrategy strategy)
void setFontStrikeOut(bool strikeOut)
If strikeOut is true, sets the text format's font with strike-out enabled (with a horizontal line thr...
void setFontHintingPreference(QFont::HintingPreference hintingPreference)
void setFontStretch(int factor)
bool fontUnderline() const
Returns true if the text format's font is underlined; otherwise returns false.
void setFontOverline(bool overline)
If overline is true, sets the text format's font to be overlined; otherwise the font is displayed non...
void setFontLetterSpacingType(QFont::SpacingType letterSpacingType)
void setFontStyleName(const QString &styleName)
void setFontItalic(bool italic)
If italic is true, sets the text format's font to be italic; otherwise the font will be non-italic.
void setFontWeight(int weight)
Sets the text format's font weight to weight.
void setFontCapitalization(QFont::Capitalization capitalization)
void setFont(const QFont &font, FontPropertiesInheritanceBehavior behavior=FontPropertiesAll)
int indexForFormat(const QTextFormat &f)
QMultiHash< size_t, int > hashes
QList< qint32 > objFormats
int createObjectIndex(const QTextFormat &f)
int objectFormatIndex(int objectIndex) const
void setObjectFormatIndex(int objectIndex, int formatIndex)
QTextFormat format(int idx) const
bool hasFormatCached(const QTextFormat &format) const
void setDefaultFont(const QFont &f)
const QFont & font() const
friend QDataStream & operator<<(QDataStream &, const QTextFormat &)
friend QDataStream & operator>>(QDataStream &, QTextFormat &)
bool hasProperty(qint32 key) const
bool operator==(const QTextFormatPrivate &rhs) const
void resolveFont(const QFont &defaultFont)
void insertProperty(qint32 key, const QVariant &value)
QVariant property(qint32 key) const
int propertyIndex(qint32 key) const
void clearProperty(qint32 key)
QTextCharFormat toCharFormat() const
Returns this format as a character format.
QString stringProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn't of QMetaType::QString ty...
QTextBlockFormat toBlockFormat() const
Returns this format as a block format.
@ OldFontLetterSpacingType
QTextLength lengthProperty(int propertyId) const
Returns the value of the property given by propertyId.
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.
int objectIndex() const
Returns the index of the format object, or -1 if the format object is invalid.
QColor colorProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn't of QMetaType::QColor typ...
bool boolProperty(int propertyId) const
Returns the value of the property specified by propertyId.
QTextFormat & operator=(const QTextFormat &rhs)
Assigns the other text format to this text format, and returns a reference to this text format.
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
friend class QTextCharFormat
QTextFormat()
Creates a new text format with an InvalidFormat.
QBrush brushProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn't of QMetaType::QBrush typ...
QTextTableFormat toTableFormat() const
Returns this format as a table format.
QTextImageFormat toImageFormat() const
Returns this format as an image format.
void setObjectType(int type)
Sets the text format's object type to type.
~QTextFormat()
Destroys this text format.
QMap< int, QVariant > properties() const
Returns a map with all properties of this text format.
QTextTableCellFormat toTableCellFormat() const
int propertyCount() const
QTextListFormat toListFormat() const
Returns this format as a list format.
bool hasProperty(int propertyId) const
Returns true if the text format has a property with the given propertyId; otherwise returns false.
QPen penProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn't of QMetaType::QPen type,...
void setObjectIndex(int object)
Sets the format object's object index.
bool operator==(const QTextFormat &rhs) const
Returns true if this text format is the same as the other text format.
QTextFrameFormat toFrameFormat() const
Returns this format as a frame format.
int type() const
Returns the type of this format.
void clearProperty(int propertyId)
Clears the value of the property given by propertyId.
void merge(const QTextFormat &other)
Merges the other format with this format; where there are conflicts the other format takes precedence...
QList< QTextLength > lengthVectorProperty(int propertyId) const
Returns the value of the property given by propertyId.
qreal doubleProperty(int propertyId) const
Returns the value of the property specified by propertyId.
QVariant property(int propertyId) const
Returns the property specified by the given propertyId.
void setBorderBrush(const QBrush &brush)
void setBorderStyle(BorderStyle style)
void setBorder(qreal border)
Sets the width (in pixels) of the frame's border.
qreal bottomMargin() const
qreal rightMargin() const
qreal margin() const
Returns the width of the frame's external margin in pixels.
void setMargin(qreal margin)
Sets the frame's margin in pixels.
QTextFrameFormat()
Constructs a text frame format object with the default properties.
QTextImageFormat()
Creates a new image format object.
Type
This enum describes the different types a length object can have.
Type type() const
Returns the type of this length object.
void setIndent(int indent)
Sets the list format's indentation.
void setStart(int indent)
QTextListFormat()
Constructs a new list format object.
void setBorderCollapse(bool borderCollapse)
QTextTableFormat()
Constructs a new table format object.
void setCellPadding(qreal padding)
Sets the cell padding for the table.
double toDouble(bool *ok=nullptr) const
Returns the variant as a double if the variant has userType() \l QMetaType::Double,...
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has userType() \l QMetaType::QVariantList.
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
float toFloat(bool *ok=nullptr) const
Returns the variant as a float if the variant has userType() \l QMetaType::Double,...
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
bool isNull() const
Returns true if this is a null variant, false otherwise.
const char * typeName() const
Returns the name of the type stored in the variant.
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
QStringList toStringList() const
Returns the variant as a QStringList if the variant has userType() \l QMetaType::QStringList,...
QHash< int, QWidget * > hash
[35multi]
QMap< QString, QString > map
[6]
QSet< QString >::iterator it
Combined button and popup list for selecting options.
QList< QString > QStringList
Constructs a string list that contains the given string, str.
static const QCssKnownValue properties[NumProperties - 1]
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
size_t qHash(const QFileSystemWatcherPathKey &key, size_t seed=0)
int qRound(qfloat16 d) noexcept
constexpr const T & qBound(const T &min, const T &val, const T &max)
GLsizei const GLfloat * v
[13]
GLenum GLuint GLenum GLsizei length
GLuint GLuint GLfloat weight
GLenum GLuint GLsizei const GLenum * props
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
QDataStream & operator>>(QDataStream &stream, QTextLength &length)
static size_t getHash(const QTextFormatPrivate *d, int format)
QDataStream & operator<<(QDataStream &stream, const QTextLength &length)
static size_t variantHash(const QVariant &variant)
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
static int toInt(const QChar &qc, int R)
QVideoFrameFormat::PixelFormat fmt
args<< 1<< 2;QJSValue threeAgain=fun.call(args);QString fileName="helloworld.qs";QFile scriptFile(fileName);if(!scriptFile.open(QIODevice::ReadOnly)) QTextStream stream(&scriptFile);QString contents=stream.readAll();scriptFile.close();myEngine.evaluate(contents, fileName);myEngine.globalObject().setProperty("myNumber", 123);...QJSValue myNumberPlusOne=myEngine.evaluate("myNumber + 1");QJSValue result=myEngine.evaluate(...);if(result.isError()) qDebug()<< "Uncaught exception at line"<< result.property("lineNumber").toInt()<< ":"<< result.toString();QPushButton *button=new QPushButton;QJSValue scriptButton=myEngine.newQObject(button);myEngine.globalObject().setProperty("button", scriptButton);myEngine.evaluate("button.checkable = true");qDebug()<< scriptButton.property("checkable").toBool();scriptButton.property("show").call();QJSEngine engine;QObject *myQObject=new QObject();myQObject- setProperty)("dynamicProperty", 3)