Esempio n. 1
0
void StarWidget::paintEvent(QPaintEvent* event)
{
	QPainter p(this);

	for(int i = 0; i < current; i++)
		p.drawPixmap(i * IMG_SIZE + SPACING, 0, starActive());

	for(int i = current; i < TOTALSTARS; i++)
		p.drawPixmap(i * IMG_SIZE + SPACING, 0, starInactive());
}
Esempio n. 2
0
void StarWidget::paintEvent(QPaintEvent *event)
{
	QPainter p(this);
	QImage star = hasFocus() ? focusedImage(starActive()) : starActive();
	QPixmap selected = QPixmap::fromImage(star);
	QPixmap inactive = QPixmap::fromImage(starInactive());
	const IconMetrics& metrics = defaultIconMetrics();


	for (int i = 0; i < current; i++)
		p.drawPixmap(i * metrics.sz_small + metrics.spacing, 0, selected);

	for (int i = current; i < TOTALSTARS; i++)
		p.drawPixmap(i * metrics.sz_small + metrics.spacing, 0, inactive);

	if (hasFocus()) {
		QStyleOptionFocusRect option;
		option.initFrom(this);
		option.backgroundColor = palette().color(QPalette::Background);
		style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &p, this);
	}
}
Esempio n. 3
0
void StarWidget::paintEvent(QPaintEvent *event)
{
    QPainter p(this);

    for (int i = 0; i < current; i++)
        p.drawPixmap(i * IMG_SIZE + SPACING, 0, starActive());

    for (int i = current; i < TOTALSTARS; i++)
        p.drawPixmap(i * IMG_SIZE + SPACING, 0, starInactive());

    if (hasFocus()) {
        QStyleOptionFocusRect option;
        option.initFrom(this);
        option.backgroundColor = palette().color(QPalette::Background);
        style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &p, this);
    }
}