[Qt-interest] QGraphicsProxyWidget Selection
David García Garzón
david.garcia at upf.edu
Fri Aug 21 04:30:02 CEST 2009
QGV is optimizing by just painting the bounding box as defined by the widget.
You should redefine the bounding box of the Item by including the selection
mark region too. Because bounding box redefinition will also intercept some
mouse events from outside the widget and this could affect interactivity in
that outer region, a safe solution is to add the selection mark as child item
so that the interation is managed independently.
On Tuesday 09 June 2009 19:29:37 Bruno Tezine wrote:
> 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
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list