class KRatingPainter |
|
Utility class that draws a row of stars for a rating value.
The KRatingPainter also allows to determine a rating value from a position in the draw area. it supports all different alignments and custom icons. For showing a rating in a widget see KRatingWidget.
Author Sebastian Trueg \since 4.1 |
|
Create a new KRatingPainter. For most cases the static methods paintRating and getRatingFromPosition should be sufficient. |
|
The alignment of the stars.
See also setAlignment |
|
The custom pixmap set to draw a star. If no custom
pixmap has been set, an invalid pixmap is returned.
See also setCustomPixmap |
|
Get the rating that would be selected if the user clicked position pos
within rect if the rating has been drawn with paintRating() using the same
rect and align values.
Returns The new rating or -1 if pos is outside of the rating area. |
|
If half steps are enabled one star equals to 2 rating
points and uneven rating values result in half-stars being
drawn.
See also setHalfStepsEnabled |
|
The icon used to draw a star. In case a custom pixmap has been set
this value is ignored.
See also setIcon, setCustomPixmap |
|
The rating can be painted in a disabled state where no color
is used and hover ratings are ignored.
See also setEnabled |
|
The layout direction. If RTL the stars
representing the rating value will be drawn from the
right.
See also setLayoutDirection |
|
The maximum rating, i.e. how many stars are drawn
in total.
See also setMaxRating |
|
Draw the rating.
painter - The painter to draw the rating to. rect - The geometry of the rating. The alignment of the rating is used relative to this value. rating - The actual rating value to draw. hoverRating - The hover rating indicates the position the user hovers the mouse pointer at. This will provide visual feedback about the new rating if the user would actually click as well as the difference to the current rating. |
|
Convenience method that paints a rating into the given rect.
LayoutDirection is read from QPainter. align - can be aligned vertically and horizontally. Using Qt.AlignJustify will insert spacing between the stars. |
|
Calculate the rating value from mouse position pos.
Returns The rating corresponding to pos or -1 if pos is outside of the configured rect. |
|
The alignment of the stars in the drawing rect. All alignment flags are supported. |
|
Set a custom pixmap. |
|
Enable or disable the rating. Default is enabled. |
|
If half steps are enabled (the default) then one rating step corresponds to half a star. |
|
Set a custom icon. Defaults to "rating". |
|
LTR or RTL |
|
The maximum rating. Defaults to 10. |
|
Set the spacing between rating pixmaps. Be aware that for justified horizontal alignment this values may be ignored. |
|
The spacing between rating pixmaps.
See also setSpacing |