StyledLabel properly obeys the frame margins now, and properly centers within the frame's
contentsRect. This means that in most styles, the topic should now be displayed with a small left margin
and vertically centered rather than too far up.
Sadly, Oxygen still seems to add some extra padding below the contentsRect(), such that the text appears
slightly misplaced.
void StyledLabel::layout() {
qreal h = 0;
void StyledLabel::layout() {
qreal h = 0;
- qreal w = frameRect().width() - 2*frameWidth();
+ qreal w = contentsRect().width();
_layout.beginLayout();
forever {
_layout.beginLayout();
forever {
-void StyledLabel::paintEvent(QPaintEvent *) {
+void StyledLabel::paintEvent(QPaintEvent *e) {
+ QFrame::paintEvent(e);
- qreal y = (frameRect().height() - _layout.boundingRect().height()) / 2;
- _layout.draw(&painter, QPointF(0, y), _extraLayoutList);
+ qreal y = contentsRect().y() + (contentsRect().height() - _layout.boundingRect().height()) / 2;
+ _layout.draw(&painter, QPointF(contentsRect().x(), y), _extraLayoutList);
}
int StyledLabel::posToCursor(const QPointF &pos) {
}
int StyledLabel::posToCursor(const QPointF &pos) {