- QRectF txtBounding = painter->boundingRect(p1.x(), p1.y() + 10, m_width, metric.height(), Qt::AlignLeft | Qt::AlignTop, ' ' + m_label + ' ');
- QPainterPath path;
- path.addRoundedRect(txtBounding, 3, 3);
- painter->fillPath(path, m_pen.color());
+ painter->setClipRect(option->rect);
+ // makes sure the text stays visible when scrolling vertical
+ int offset = scene()->views()[0]->verticalScrollBar()->value();
+
+ QRectF txtBounding = painter->boundingRect(p1.x(), p1.y() + offset, m_width, metric.height(), Qt::AlignLeft | Qt::AlignTop, m_label);
+ painter->setBrush(QBrush(m_pen.color()));
+ painter->drawRoundedRect(txtBounding.adjusted(-5, -5, 2, 1), 3, 3);