KDE 4.9 PyKDE API Reference

- KDE's Python API

# KRatingWidget Class Reference

`from PyKDE4.kdeui import *`

Inherits: QFrame → QWidget → QObject

## Detailed Description

\class KRatingWidget kratingwidget.h KDE/KRatingWidget

Displays a rating value as a row of pixmaps.

The KRatingWidget displays a range of stars or other arbitrary pixmaps and allows the user to select a certain number by mouse.

\sa KRatingPainter

Author:
  Sebastian Trueg <trueg@kde.org>

## Signals

| ratingChanged (int rating)

## Methods

| __init__ (self, QWidget parent=0)
Qt::Alignment | alignment (self)
bool | halfStepsEnabled (self)
QIcon | icon (self)
Qt::LayoutDirection | layoutDirection (self)
| leaveEvent (self, QEvent e)
int | maxRating (self)
| mouseMoveEvent (self, QMouseEvent e)
| mousePressEvent (self, QMouseEvent e)
| paintEvent (self, QPaintEvent e)
long | rating (self)
| resizeEvent (self, QResizeEvent e)
| setAlignment (self, Qt::Alignment align)
| setCustomPixmap (self, QPixmap pixmap)
| setHalfStepsEnabled (self, bool enabled)
| setIcon (self, QIcon icon)
| setLayoutDirection (self, Qt::LayoutDirection direction)
| setMaxRating (self, int max)
| setOnlyPaintFullSteps (self, bool a0)
| setPixmap (self, QPixmap a0)
| setPixmapSize (self, int size)
| setRating (self, int rating)
| setSpacing (self, int a0)
QSize | sizeHint (self)
int | spacing (self)

## Signal Documentation

ratingChanged | ( | int | rating
| ) |  |  |

This signal is emitted when the rating is changed.

Signal syntax:
  `QObject.connect(source, SIGNAL("ratingChanged(int)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QWidget | parent=0
| ) |  |  |

Creates a new rating widget.

Qt::Alignment alignment | ( |  | self ) |

The alignment of the stars.

\sa setAlignment

bool halfStepsEnabled | ( |  | self ) |

If half steps are enabled one star equals to 2 rating points and uneven rating values result in half-stars being drawn.

\sa setHalfStepsEnabled

QIcon icon | ( |  | self ) |

The icon used to draw a star. In case a custom pixmap has been set this value is ignored.

\sa setIcon, setCustomPixmap

Qt::LayoutDirection layoutDirection | ( |  | self ) |

The layout direction. If RTL the stars representing the rating value will be drawn from the right.

\sa setLayoutDirection

leaveEvent | ( | self, |
|  | QEvent | e
| ) |  |  |

int maxRating | ( |  | self ) |

Returns:
  the maximum possible rating.

mouseMoveEvent | ( | self, |
|  | QMouseEvent | e
| ) |  |  |

mousePressEvent | ( | self, |
|  | QMouseEvent | e
| ) |  |  |

paintEvent | ( | self, |
|  | QPaintEvent | e
| ) |  |  |

long rating | ( |  | self ) |

Returns:
  The current rating.

resizeEvent | ( | self, |
|  | QResizeEvent | e
| ) |  |  |

setAlignment | ( | self, |
|  | Qt::Alignment | align
| ) |  |  |

The alignment of the stars in the drawing rect. All alignment flags are supported.

setCustomPixmap | ( | self, |
|  | QPixmap | pixmap
| ) |  |  |

Set a custom pixmap.

setHalfStepsEnabled | ( | self, |
|  | bool | enabled
| ) |  |  |

If half steps are enabled (the default) then one rating step corresponds to half a star.

setIcon | ( | self, |
|  | QIcon | icon
| ) |  |  |

Set a custom icon. Defaults to "rating".

setLayoutDirection | ( | self, |
|  | Qt::LayoutDirection | direction
| ) |  |  |

LTR or RTL

setMaxRating | ( | self, |
|  | int | max
| ) |  |  |

Deprecated:
  use setMaxRating( int max )

setOnlyPaintFullSteps | ( | self, |
|  | bool | a0
| ) |  |  |

Deprecated:
  Use setHalfStepsEnabled

setPixmap | ( | self, |
|  | QPixmap | a0
| ) |  |  |

Set the pixap to be used to display a rating step. By default the "rating" pixmap is loaded.

Deprecated:
  use setCustomPixmap

setPixmapSize | ( | self, |
|  | 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.

setRating | ( | self, |
|  | int | rating
| ) |  |  |

Deprecated:
  use setRating( int rating )

setSpacing | ( | self, |
|  | int | a0
| ) |  |  |

Set the spacing between the pixmaps. The default is 0.

QSize sizeHint | ( |  | self ) |

int spacing | ( |  | self ) |

The spacing between the rating stars.

\sa setSpacing