Remove border around qgraphicsitem.

--HG--
branch : develop
This commit is contained in:
dismine 2014-07-30 11:58:40 +03:00
parent 14edede972
commit 8acb3f7578
6 changed files with 45 additions and 3 deletions

View File

@ -66,6 +66,19 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP
controlLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
}
//---------------------------------------------------------------------------------------------------------------------
void VControlPointSpline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
/* From question on StackOverflow
* https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected
*
* There's no interface to disable the drawing of the selection border for the build-in QGraphicsItems. The only way
* I can think of is derive your own items from the build-in ones and override the paint() function:*/
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
QGraphicsEllipseItem::paint(painter, &myOption, widget);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.

View File

@ -42,6 +42,7 @@ class VControlPointSpline : public QObject, public QGraphicsEllipseItem
public:
VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, const QPointF &controlPoint,
const QPointF &splinePoint, QGraphicsItem * parent = nullptr);
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
signals:
/**
* @brief ControlPointChangePosition emit when control point change position.

View File

@ -62,6 +62,19 @@ void VSimpleCurve::ChangedActivDraw(const bool &flag)
setPen(QPen(*currentColor, qApp->toPixel(qApp->widthHairLine())/ *factor));
}
//---------------------------------------------------------------------------------------------------------------------
void VSimpleCurve::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
/* From question on StackOverflow
* https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected
*
* There's no interface to disable the drawing of the selection border for the build-in QGraphicsItems. The only way
* I can think of is derive your own items from the build-in ones and override the paint() function:*/
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
QGraphicsPathItem::paint(painter, &myOption, widget);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
@ -73,7 +86,7 @@ void VSimpleCurve::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
emit Choosed(id);
}
QGraphicsItem::mouseReleaseEvent(event);
QGraphicsPathItem::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -42,6 +42,7 @@ class VSimpleCurve : public QObject, public QGraphicsPathItem
public:
VSimpleCurve(quint32 id, Qt::GlobalColor *currentColor, qreal *factor = nullptr, QObject *parent = 0);
void ChangedActivDraw(const bool &flag);
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
signals:
/**
* @brief Choosed send id when clicked.

View File

@ -40,9 +40,22 @@
* @param factor scale factor.
*/
VSimpleSplinePath::VSimpleSplinePath(VPattern *doc, VContainer *data, quint32 id, qreal *factor)
:VAbstractTool(doc, data, id), factor(factor)
:VAbstractTool(doc, data, id), QGraphicsPathItem(), factor(factor)
{}
//---------------------------------------------------------------------------------------------------------------------
void VSimpleSplinePath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
/* From question on StackOverflow
* https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected
*
* There's no interface to disable the drawing of the selection border for the build-in QGraphicsItems. The only way
* I can think of is derive your own items from the build-in ones and override the paint() function:*/
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
QGraphicsPathItem::paint(painter, &myOption, widget);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief mouseReleaseEvent handle mouse release events.
@ -54,7 +67,7 @@ void VSimpleSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
emit ChoosedTool(id, SceneObject::SplinePath);
}
QGraphicsItem::mouseReleaseEvent(event);
QGraphicsPathItem::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -41,6 +41,7 @@ class VSimpleSplinePath : public VAbstractTool, public QGraphicsPathItem
Q_OBJECT
public:
VSimpleSplinePath(VPattern *doc, VContainer *data, quint32 id, qreal *factor);
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
protected:
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );