本页内容

QPlaceRatings Class

QPlaceRatings 类保存了关于某个地点的评分信息。更多内容...

Header: #include <QPlaceRatings>
qmake: QT += location

属性

公开活动

QPlaceRatings()
QPlaceRatings(const QPlaceRatings &other)
QPlaceRatings(QPlaceRatings &&other)
~QPlaceRatings()
qreal average() const
int count() const
bool isEmpty() const
qreal maximum() const
void setAverage(qreal average)
void setCount(int count)
void setMaximum(qreal max)
QPlaceRatings &operator=(const QPlaceRatings &other)
bool operator!=(const QPlaceRatings &lhs, const QPlaceRatings &rhs)
bool operator==(const QPlaceRatings &lhs, const QPlaceRatings &rhs)

详细说明

评分信息用于描述一个地方被认为有多好。通常,这些信息以星级形式呈现。average() 函数返回一个汇总评分值,该值基于maximum() 函数给出的最高可能评分。

qDebug() << QString("This place rated ") + place.ratings().average()
            + "out of " + place.ratings().maximum() + "stars";

属性文档

average : qreal

该属性存储各项评分的平均值。

访问函数:

qreal average() const
void setAverage(qreal average)

count : int

该属性存储个人评分的总数。

访问函数:

int count() const
void setCount(int count)

maximum : qreal

该属性存储可能的最大评分值。

访问函数:

qreal maximum() const
void setMaximum(qreal max)

成员函数文档

QPlaceRatings::QPlaceRatings()

创建一个新的评分对象。

[noexcept] QPlaceRatings::QPlaceRatings(const QPlaceRatings &other)

创建other 的副本。

[constexpr noexcept default] QPlaceRatings::QPlaceRatings(QPlaceRatings &&other)

通过Move构造一个QPlaceRatings 的实例。

[noexcept] QPlaceRatings::~QPlaceRatings()

销毁 ratings 对象。

bool QPlaceRatings::isEmpty() const

如果该场所评分的所有字段均为 0,则返回 true;否则返回 false。

[noexcept] QPlaceRatings &QPlaceRatings::operator=(const QPlaceRatings &other)

将other 分配给此评分对象,并返回对此评分对象的引用。

相关的非成员

[noexcept] bool operator!=(const QPlaceRatings &lhs, const QPlaceRatings &rhs)

如果 `lhs ` 不等于 `rhs`,则返回 true;否则返回 false。

[noexcept] bool operator==(const QPlaceRatings &lhs, const QPlaceRatings &rhs)

如果 `lhs ` 等于 `rhs`,则返回 true;否则返回 false。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.