KRatingWidget

KDE 4.2 PyKDE API Reference

- KDE's Python API

# KRatingWidget Class Reference

`from PyKDE4.nepomuk import *`

Inherits: QFrame → QWidget → QObject

## Detailed Description

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 (long rating)
| 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)
| ratingChanged (self, long rating)
| ratingChanged (self, int rating)
| 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)
| setMaxRating (self, long max)
| setOnlyPaintFullSteps (self, bool a0)
| setPixmap (self, QPixmap a0)
| setPixmapSize (self, int size)
| setRating (self, int rating)
| setRating (self, long rating)
| setSpacing (self, int a0)
QSize | sizeHint (self)
int | spacing (self)

## 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.

ratingChanged | ( | self, |
|  | long | rating
| ) |  |  |

Emitted if the rating is changed by user interaction (ie. mouse click). A call to setRating does not trigger this signal.

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

ratingChanged | ( | self, |
|  | int | rating
| ) |  |  |

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

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
| ) |  |  |

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.

setMaxRating | ( | self, |
|  | long | 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 dependant on the size of the widget itself.

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

Set the current rating. Calling this method will NOT trigger the ratingChanged signal.

setRating | ( | self, |
|  | long | rating
| ) |  |  |

Deprecated:
  use setRating( int max )

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