I have a QgraphicsView widget with lots of items on scene.Iam panning the view on ctr+left mouse click and zooming it to rectangle of rubber band created with left mouse button drag. Iam not able to see rubber band selection rectangle (dotted lines) whereas rubberband selection functionality works fine.Can anybody help me understand this.I use these flags in my view

setTransformationAnchor(QGraphicsView::AnchorUnder Mouse);
setViewportUpdateMode(QGraphicsView:: SmartViewportUpdate);
setRenderHints(QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform);
setOptimizationFlag(QGraphicsView:: DontSavePainterState,true);
setCacheMode(QGraphicsView::CacheBackground);
setOptimizationFlag(QGraphicsView:: DontAdjustForAntialiasing);
setViewport(new QGLWidget);
below are my event handlers.

mouse press event handler

void MyView::mousePressEvent(QMouseEvent* event)
{
if(event->button()==Qt::LeftButton)
{
if(event->modifiers()==Qt::ControlModifier)
{
setDragMode(QGraphicsView::NoDrag);
m_rubberBandActive = false;
mousepressed=true;
m_lastDragPos = event->pos();
return;
}
else
{
setDragMode(QGraphicsView::RubberBandDrag);
m_rubberBandOrigin = event->pos();
m_rubberBandActive = true;
}
}
event->accept();
}
else
{
QWidget::mousePressEvent(event);
}
}

mouse move event

void MyView::mouseMoveEvent(QMouseEvent* event)
{
if(mousepressed)
{
QPointF delta = mapToScene(event->pos()) - mapToScene(m_lastDragPos);
this->panView(delta);
m_lastDragPos = event->pos();
return;
}
event->accept();
}



mouse release event Handler

void MyView::mouseReleaseEvent(QMouseEvent *event)
{
if (m_rubberBandActive)
{
QPoint rubberBandEnd = event->pos();
QRectF zoomRectInScene = QRectF(mapToScene(m_rubberBandOrigin),mapToScene(r ubberBandEnd));

fitInView(zoomRectInScene, Qt::KeepAspectRatio);
m_rubberBandActive = false;
}

mousepressed=false;
event->accept();
}

pan view

void MyView:: panView(QPointF delta)
{
QPoint viewCenter(viewport()->width() / 2 + delta.x(), viewport()->height() / 2 + delta.y());
QPointF newCenter = mapToScene(viewCenter);
centerOn(newCenter);
}