[Qt-interest] QGraphicsProxyWidget Selection
Bruno Tezine
bruno at tezine.com
Tue Jun 9 19:29:37 CEST 2009
Hi,
I'm trying to paint a widget selection frame on a QGraphicsProxyWidget to allow widget resize and selection, but since this frame is outside the widget, it's only painted when I minimize/restore the application. Why?
Follow below my paint event:
void Item::paint(QPainter *painter,const QStyleOptionGraphicsItem *option,QWidget *widget)
{
if(option->state & QStyle::State_Selected)//selected
{
qDebug()<<"exposed"<<option->exposedRect;
qDebug()<<"device width"<<painter->device()->width();
QGraphicsProxyWidget::paint(painter,option,widget);
bottomLeftSelect.setRect(-8, rect().height()-1, 8,8);
bottomRightSelect.setRect(rect().width(),rect().height()-1,8,8);
topLeftSelect.setRect(-8,-8,8,8);
topRightSelect.setRect(rect().width(),-8,8,8);
middleBottomSelect.setRect(rect().width()/2-4, rect().height(),8,8);
middleTopSelect.setRect(rect().width()/2-4, -8,8,8);
middleRightSelect.setRect(rect().width(), rect().height()/2-4, 8,8);
middleLeftSelect.setRect(-8, rect().height()/2-4, 8,8);
painter->setPen(selectPen);
painter->fillRect(bottomLeftSelect, QBrush(Qt::blue));
painter->fillRect(topLeftSelect, QBrush(Qt::blue));
painter->fillRect(topRightSelect, QBrush(Qt::blue));
painter->fillRect(bottomRightSelect, QBrush(Qt::blue));
painter->fillRect(middleBottomSelect, QBrush(Qt::blue));
painter->fillRect(middleRightSelect, QBrush(Qt::blue));
painter->fillRect(middleTopSelect, QBrush(Qt::blue));
painter->fillRect(middleLeftSelect, QBrush(Qt::blue));
painter->drawRect(boundingRect().adjusted(14,14,-14,-14));
return;
}
}
Thanks/Bruno
More information about the Qt-interest-old
mailing list