if only need to draw a arrow in the top of the view is more simple subclass a view and draw the arrow in the drawForeground() function
{
public:
explicit CustomView
( QWidget * parent
= 0 )
protected:
{
painter
->setPen
(QPen(Qt
::red,
3));
painter->drawLine( rect.topLeft(), rect.bottomRight() );
painter->drawLine( rect.topRight(), rect.bottomLeft() );
}
};
class CustomView : public QGraphicsView
{
public:
explicit CustomView ( QWidget * parent = 0 )
: QGraphicsView (parent){};
protected:
void drawForeground ( QPainter * painter, const QRectF & rect )
{
painter->setPen(QPen(Qt::red,3));
painter->drawLine( rect.topLeft(), rect.bottomRight() );
painter->drawLine( rect.topRight(), rect.bottomLeft() );
}
};
To copy to clipboard, switch view to plain text mode
this draw a big X in the view.
convert the code to draw a arrow must be trivial. but is late and i want to sleep
Bookmarks