JKQtExtras
a library of useful Qt widgets and tools
JKQTEStarRatingWidget Class Reference

a rating widget which displays five stars where the user may select how many are selected More...

#include <jkqtestarratingwidget.h>

Inheritance diagram for JKQTEStarRatingWidget:
Collaboration diagram for JKQTEStarRatingWidget:

Public Slots

void setDarkStarImage (const QPixmap &darkStarImage)
 sets the pixmap to use for an unselected star More...
 
void setFrameRect (const QRect &)
 sets the frame rectangle of the widget (see QFrame::setFrameRect()) More...
 
void setFrameShadow (Shadow)
 sets the frame shadow of the widget (see QFrame::setFrameShadow()) More...
 
void setFrameShape (Shape)
 sets the frame shape of the widget (see QFrame::setFrameShape()) More...
 
void setFrameStyle (int)
 sets the frame style of the widget (see QFrame::setFrameStyle()) More...
 
void setLineWidth (int)
 sets the frame line width of the widget (see QFrame::setLineWidth()) More...
 
void setMaximum (int value)
 sets the current maximum rating More...
 
void setMidLineWidth (int)
 sets the frame mid line width of the widget (see QFrame::setMidLineWidth()) More...
 
void setNoStarImage (const QPixmap &noStarImage)
 sets the pixmap to use for no stars at all (rating() ==0 ) More...
 
void setRating (int value)
 sets the current rating (between 0 and maximum() ) More...
 
void setStarImage (const QPixmap &starImage)
 sets the pixmap to use for a selected star More...
 

Signals

void ratingChanged (int rating)
 signal emitted when the rating changes More...
 

Public Member Functions

 JKQTEStarRatingWidget (QWidget *parent=NULL)
 
virtual ~JKQTEStarRatingWidget ()
 
QPixmap darkStarImage () const
 the pixmap to use for an unselected star More...
 
int maximum () const
 returns the current maximum rating More...
 
QPixmap noStarImage () const
 the pixmap to use for no stars at all (rating() ==0 ) More...
 
int rating () const
 returns the current rating (between 0 and maximum() ) More...
 
QPixmap starImage () const
 the pixmap to use for a selected star More...
 

Protected Member Functions

virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void paintEvent (QPaintEvent *event)
 
void setWidgetSizes ()
 

Protected Attributes

QPixmap m_darkStarImage
 
int m_maximum
 
QPixmap m_noStarImage
 
int m_rating
 
QPixmap m_starImage
 

Properties

QPixmap darkStarImage
 
int data
 
QPixmap noStarImage
 
int rating
 
QPixmap starImage
 

Detailed Description

a rating widget which displays five stars where the user may select how many are selected

Screenshot:

Basic usage is simple:

starRating->setMaximum(5);
starRating->setRating(3);
[labRating,starRating] (int r) {
labRating->setText(QString::number(r)+" / "+QString::number(starRating->maximum()));
});

You can set the images/icons to be used for present/unpresent stars and the limiter to the left that allows to set rating 0 when clicked:

Constructor & Destructor Documentation

◆ JKQTEStarRatingWidget()

JKQTEStarRatingWidget::JKQTEStarRatingWidget ( QWidget *  parent = NULL)

Default constructor

◆ ~JKQTEStarRatingWidget()

virtual JKQTEStarRatingWidget::~JKQTEStarRatingWidget ( )
virtual

Default destructor

Member Function Documentation

◆ darkStarImage()

QPixmap JKQTEStarRatingWidget::darkStarImage ( ) const

the pixmap to use for an unselected star

◆ maximum()

int JKQTEStarRatingWidget::maximum ( ) const

returns the current maximum rating

◆ mouseReleaseEvent()

virtual void JKQTEStarRatingWidget::mouseReleaseEvent ( QMouseEvent *  event)
protectedvirtual

◆ noStarImage()

QPixmap JKQTEStarRatingWidget::noStarImage ( ) const

the pixmap to use for no stars at all (rating() ==0 )

◆ paintEvent()

virtual void JKQTEStarRatingWidget::paintEvent ( QPaintEvent *  event)
protectedvirtual

◆ rating()

int JKQTEStarRatingWidget::rating ( ) const

returns the current rating (between 0 and maximum() )

◆ ratingChanged

void JKQTEStarRatingWidget::ratingChanged ( int  rating)
signal

signal emitted when the rating changes

◆ setDarkStarImage

void JKQTEStarRatingWidget::setDarkStarImage ( const QPixmap &  darkStarImage)
slot

sets the pixmap to use for an unselected star

◆ setFrameRect

void JKQTEStarRatingWidget::setFrameRect ( const QRect &  )
slot

sets the frame rectangle of the widget (see QFrame::setFrameRect())

◆ setFrameShadow

void JKQTEStarRatingWidget::setFrameShadow ( Shadow  )
slot

sets the frame shadow of the widget (see QFrame::setFrameShadow())

◆ setFrameShape

void JKQTEStarRatingWidget::setFrameShape ( Shape  )
slot

sets the frame shape of the widget (see QFrame::setFrameShape())

◆ setFrameStyle

void JKQTEStarRatingWidget::setFrameStyle ( int  )
slot

sets the frame style of the widget (see QFrame::setFrameStyle())

◆ setLineWidth

void JKQTEStarRatingWidget::setLineWidth ( int  )
slot

sets the frame line width of the widget (see QFrame::setLineWidth())

◆ setMaximum

void JKQTEStarRatingWidget::setMaximum ( int  value)
slot

sets the current maximum rating

◆ setMidLineWidth

void JKQTEStarRatingWidget::setMidLineWidth ( int  )
slot

sets the frame mid line width of the widget (see QFrame::setMidLineWidth())

◆ setNoStarImage

void JKQTEStarRatingWidget::setNoStarImage ( const QPixmap &  noStarImage)
slot

sets the pixmap to use for no stars at all (rating() ==0 )

◆ setRating

void JKQTEStarRatingWidget::setRating ( int  value)
slot

sets the current rating (between 0 and maximum() )

◆ setStarImage

void JKQTEStarRatingWidget::setStarImage ( const QPixmap &  starImage)
slot

sets the pixmap to use for a selected star

◆ setWidgetSizes()

void JKQTEStarRatingWidget::setWidgetSizes ( )
protected

◆ starImage()

QPixmap JKQTEStarRatingWidget::starImage ( ) const

the pixmap to use for a selected star

Member Data Documentation

◆ m_darkStarImage

QPixmap JKQTEStarRatingWidget::m_darkStarImage
protected

◆ m_maximum

int JKQTEStarRatingWidget::m_maximum
protected

◆ m_noStarImage

QPixmap JKQTEStarRatingWidget::m_noStarImage
protected

◆ m_rating

int JKQTEStarRatingWidget::m_rating
protected

◆ m_starImage

QPixmap JKQTEStarRatingWidget::m_starImage
protected

Property Documentation

◆ darkStarImage

QPixmap JKQTEStarRatingWidget::darkStarImage
readwrite

◆ data

int JKQTEStarRatingWidget::data
readwrite

◆ noStarImage

QPixmap JKQTEStarRatingWidget::noStarImage
readwrite

◆ rating

int JKQTEStarRatingWidget::rating
readwrite

◆ starImage

QPixmap JKQTEStarRatingWidget::starImage
readwrite

The documentation for this class was generated from the following file:
JKQTEStarRatingWidget::JKQTEStarRatingWidget
JKQTEStarRatingWidget(QWidget *parent=NULL)
JKQTEStarRatingWidget::maximum
int maximum() const
returns the current maximum rating
JKQTEStarRatingWidget::setRating
void setRating(int value)
sets the current rating (between 0 and maximum() )
JKQTEStarRatingWidget
a rating widget which displays five stars where the user may select how many are selected
Definition: jkqtestarratingwidget.h:46
JKQTEStarRatingWidget::setMaximum
void setMaximum(int value)
sets the current maximum rating
JKQTEStarRatingWidget::ratingChanged
void ratingChanged(int rating)
signal emitted when the rating changes