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 "vgraphicssimpletextitem.h"
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
|
#include <QStyle>
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -63,6 +64,19 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphic
|
||||||
this->setAcceptHoverEvents(true);
|
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.
|
* @brief itemChange handle item change.
|
||||||
|
|
|
@ -39,15 +39,11 @@ class VGraphicsSimpleTextItem : public QObject, public QGraphicsSimpleTextItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VGraphicsSimpleTextItem(QGraphicsItem *parent = nullptr);
|
VGraphicsSimpleTextItem(QGraphicsItem *parent = nullptr);
|
||||||
|
|
||||||
VGraphicsSimpleTextItem( const QString & text, QGraphicsItem *parent = nullptr );
|
VGraphicsSimpleTextItem( const QString & text, QGraphicsItem *parent = nullptr );
|
||||||
/**
|
|
||||||
* @brief FontSize return label font size.
|
qint32 FontSize()const;
|
||||||
* @return font size.
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||||
*/
|
|
||||||
qint32 FontSize()const {return fontSize;}
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* @brief NameChangePosition emit when label change position.
|
* @brief NameChangePosition emit when label change position.
|
||||||
|
@ -69,4 +65,14 @@ private:
|
||||||
qint32 fontSize;
|
qint32 fontSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief FontSize return label font size.
|
||||||
|
* @return font size.
|
||||||
|
*/
|
||||||
|
inline qint32 VGraphicsSimpleTextItem::FontSize() const
|
||||||
|
{
|
||||||
|
return fontSize;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // VGRAPHICSSIMPLETEXTITEM_H
|
#endif // VGRAPHICSSIMPLETEXTITEM_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user