Add background color to marker label

This commit is contained in:
Thomas Wilshaw
2021-11-08 22:32:42 +00:00
parent bb1aa136b3
commit 7b14b7f232
+5 -1
View File
@@ -93,7 +93,9 @@ void Marker::paintEvent(QPaintEvent *event)
} else {
p.setPen(Qt::black);
}
p.setBrush(ColorCoding::GetColor(marker_color_).toQColor());
QColor color = ColorCoding::GetColor(marker_color_).toQColor();
p.setBrush(color);
p.setRenderHint(QPainter::Antialiasing);
@@ -112,6 +114,8 @@ void Marker::paintEvent(QPaintEvent *event)
if (!name_.isEmpty()) {
resize(marker_width_ + fm.horizontalAdvance(name_) + fm.horizontalAdvance(" "), marker_height_);
color.setAlphaF(0.5);
p.fillRect(x, y, fm.horizontalAdvance(name_) + fm.horizontalAdvance(" ") * 2 + half_width, -marker_height_, color);
p.drawText(x + marker_width_, y - half_marker_height, name_);
} else {
resize(marker_width_, marker_height_);