KRatingWidget Class
Displays a rating value as a row of pixmaps. More...
- Header:
#include <KRatingWidget> - CMake:
find_package(KF6 REQUIRED COMPONENTS WidgetsAddons)
target_link_libraries(mytarget PRIVATE KF6::WidgetsAddons) - Inherits: QFrame
List of all members, including inherited members
Properties
- alignment : Qt::Alignment
- halfStepsEnabled : bool
- icon : QIcon
- maxRating : int
- rating : int
- spacing : int
Public Functions
- KRatingWidget(QWidget *parent = nullptr)
- Qt::Alignment alignment() const
- bool halfStepsEnabled() const
- QIcon icon() const
- Qt::LayoutDirection layoutDirection() const
- int maxRating() const
- int rating() const
- int spacing() const
Public Slots
- void setAlignment(Qt::Alignment align)
- void setCustomPixmap(const QPixmap &pixmap)
- void setHalfStepsEnabled(bool enabled)
- void setIcon(const QIcon &icon)
- void setLayoutDirection(Qt::LayoutDirection direction)
- void setMaxRating(int max)
- void setPixmapSize(int size)
- void setRating(int rating)
- void setSpacing(int)
Signals
Detailed Description
The KRatingWidget displays a range of stars or other arbitrary pixmaps and allows the user to select a certain number by mouse.
See also KRatingPainter
Property Documentation
alignment : Qt::Alignment
Access functions:
Qt::Alignmentalignment() constvoidsetAlignment(Qt::Alignmentalign)
halfStepsEnabled : bool
Access functions:
boolhalfStepsEnabled() constvoidsetHalfStepsEnabled(boolenabled)
icon : QIcon
Access functions:
maxRating : int
Access functions:
intmaxRating() constvoidsetMaxRating(intmax)
rating : int
Access functions:
spacing : int
Access functions:
intspacing() constvoidsetSpacing(int)
Member Function Documentation
[explicit] KRatingWidget::KRatingWidget(QWidget *parent = nullptr)
Creates a new rating widget.
Qt::Alignment KRatingWidget::alignment() const
The alignment of the stars.
Note: Getter function for property alignment.
See also setAlignment
bool KRatingWidget::halfStepsEnabled() const
If half steps are enabled one star equals to 2 rating points and uneven rating values result in half-stars being drawn.
Note: Getter function for property halfStepsEnabled.
See also setHalfStepsEnabled
QIcon KRatingWidget::icon() const
The icon used to draw a star. In case a custom pixmap has been set this value is ignored.
Note: Getter function for property icon.
See also setIcon, setCustomPixmap
Qt::LayoutDirection KRatingWidget::layoutDirection() const
The layout direction.
If RTL the stars representing the rating value will be drawn from the right.
See also setLayoutDirection
int KRatingWidget::maxRating() const
Returns the maximum possible rating.
Note: Getter function for property maxRating.
See also setMaxRating()
int KRatingWidget::rating() const
Returns the current rating.
Note: Getter function for property rating.
See also setRating()
[signal] void KRatingWidget::ratingChanged(int rating)
This signal is emitted when the rating is changed.
[slot] void KRatingWidget::setAlignment(Qt::Alignment align)
The alignment of the stars in the drawing rect. All alignment flags are supported.
Note: Setter function for property alignment.
See also alignment()
[slot] void KRatingWidget::setCustomPixmap(const QPixmap &pixmap)
Set a custom pixmap.
[slot] void KRatingWidget::setHalfStepsEnabled(bool enabled)
If half steps are enabled (the default) then one rating step corresponds to half a star.
Note: Setter function for property halfStepsEnabled.
See also halfStepsEnabled()
[slot] void KRatingWidget::setIcon(const QIcon &icon)
Set a custom icon. Defaults to "rating".
Note: Setter function for property icon.
See also icon()
[slot] void KRatingWidget::setLayoutDirection(Qt::LayoutDirection direction)
LTR or RTL
See also layoutDirection()
[slot] void KRatingWidget::setMaxRating(int max)
Set the maximum allowed rating value. The default is 10 which means that a rating from 1 to 10 is selectable. If max is uneven steps are automatically only allowed full.
Note: Setter function for property maxRating.
See also maxRating()
[slot] void KRatingWidget::setPixmapSize(int size)
Set the recommended size of the pixmaps. This is only used for the sizeHint. The actual size is always dependent on the size of the widget itself.
[slot] void KRatingWidget::setRating(int rating)
Set the current rating. Calling this method will trigger the ratingChanged signal if rating is different from the previous rating.
Note: Setter function for property rating.
See also rating()
[slot] void KRatingWidget::setSpacing(int)
Set the spacing between the pixmaps. The default is 0.
Note: Setter function for property spacing.
See also spacing()
int KRatingWidget::spacing() const
The spacing between the rating stars.
Note: Getter function for property spacing.
See also setSpacing