Remove border around point label.
--HG-- branch : develop
This commit is contained in:
parent
41a8a46b2f
commit
1f9c1e623e
|
@ -29,6 +29,7 @@
|
|||
#include "vgraphicssimpletextitem.h"
|
||||
#include <QFont>
|
||||
#include <QBrush>
|
||||
#include <QStyle>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -63,6 +64,19 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphic
|
|||
this->setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VGraphicsSimpleTextItem::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;
|
||||
QGraphicsSimpleTextItem::paint(painter, &myOption, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief itemChange handle item change.
|
||||
|
|
|
@ -39,15 +39,11 @@ class VGraphicsSimpleTextItem : public QObject, public QGraphicsSimpleTextItem
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VGraphicsSimpleTextItem(QGraphicsItem *parent = nullptr);
|
||||
VGraphicsSimpleTextItem( const QString & text, QGraphicsItem *parent = nullptr );
|
||||
|
||||
VGraphicsSimpleTextItem(QGraphicsItem * parent = nullptr);
|
||||
|
||||
VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent = nullptr );
|
||||
/**
|
||||
* @brief FontSize return label font size.
|
||||
* @return font size.
|
||||
*/
|
||||
qint32 FontSize()const {return fontSize;}
|
||||
qint32 FontSize()const;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||
signals:
|
||||
/**
|
||||
* @brief NameChangePosition emit when label change position.
|
||||
|
@ -61,12 +57,22 @@ signals:
|
|||
void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
|
||||
protected:
|
||||
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
|
||||
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent *event );
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent *event );
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent *event );
|
||||
private:
|
||||
/** @brief fontSize label font size. */
|
||||
qint32 fontSize;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief FontSize return label font size.
|
||||
* @return font size.
|
||||
*/
|
||||
inline qint32 VGraphicsSimpleTextItem::FontSize() const
|
||||
{
|
||||
return fontSize;
|
||||
}
|
||||
|
||||
#endif // VGRAPHICSSIMPLETEXTITEM_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user