Пример #1
0
void KUnitItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget)
{
    Q_UNUSED(widget);
    Q_UNUSED(painter);

    if(option->state & QStyle::State_Selected)
    {
        if(myMode != MouseMode_DRAW)
        {
            showResizeFocus(true);
            showRotateItem(true);
        }

    }
    else
    {
        if(myMode != MouseMode_DRAW)
        {
            showResizeFocus(false);
            showRotateItem(false);
        }

    }
}
Пример #2
0
void EObject::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget)
{
	Q_UNUSED(widget);

    QColor fillColor = QColor(100,100,255);
	if (option->state & QStyle::State_Selected) {fillColor = fillColor.darker(150);setCursor(Qt::SizeAllCursor);}
    if (option->state & QStyle::State_MouseOver) fillColor = fillColor.lighter(125);

	if(option->state & QStyle::State_Selected)
	{
		//Ìî³ä¾ØÐεÄÑÕÉ«
		painter->fillRect(margin, margin, width-margin*2, height-margin*2 ,fillColor);
		painter->setPen(Qt::DotLine);
		//»­Ñ¡ÔñµÄÐéÏß¿ò
		painter->drawRect(margin, margin, width-margin*2, height-margin*2);
		showResizeFocus(true);
	}
	else
	{
		painter->fillRect(margin, margin, width-margin*2, height-margin*2 ,fillColor);
		painter->drawRect(margin, margin, width-margin*2, height-margin*2);
		showResizeFocus(false);
	}
}