{
protected :
static bool s_show ;
public :
MyEllipseItem( qreal x, qreal y, qreal w, qreal h )
{
setFlag( ItemIsSelectable, true ) ;
}
static void setEllipsesVisible( bool v ) { s_show=v ; }
protected :
{
if( s_show )
}
virtual QVariant itemChange
( GraphicsItemChange change,
const QVariant & value
) {
{
// value is the new state.
bool newState = value.toBool() ;
}
}
} ;
class MyEllipseItem : public QGraphicsEllipseItem
{
protected :
static bool s_show ;
public :
MyEllipseItem( qreal x, qreal y, qreal w, qreal h )
: QGraphicsEllipseItem(x,y,w,h)
{
setFlag( ItemIsSelectable, true ) ;
}
static void setEllipsesVisible( bool v ) { s_show=v ; }
protected :
virtual void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
if( s_show )
QGraphicsEllipseItem::paint(painter,option,widget) ;
}
virtual QVariant itemChange( GraphicsItemChange change, const QVariant & value )
{
if (change == QGraphicsItem::ItemSelectedChange )
{
// value is the new state.
bool newState = value.toBool() ;
return QVariant( newState&&s_show ) ;
}
return QGraphicsItem::itemChange(change, value);
}
} ;
To copy to clipboard, switch view to plain text mode
Bookmarks