So close yet so far.
I over-rode the paintEvent thusly:
{
drawFrame(&painter);
int flags
= QStyle::visualAlignment(layoutDirection
(),
QFlag(alignment
()));
QRect theFrameRect
= frameRect
();
painter.save();
painter.scale(-1.0, 1.0);
style->drawItemText(&painter, theFrameRect, flags, palette(), isEnabled(), text(), foregroundRole());
painter.restore();
}
void MirrorLabel::paintEvent(QPaintEvent *)
{
QStyle *style = QWidget::style();
QPainter painter(this);
drawFrame(&painter);
int flags = QStyle::visualAlignment(layoutDirection(), QFlag(alignment()));
QRect theFrameRect = frameRect();
painter.save();
painter.scale(-1.0, 1.0);
style->drawItemText(&painter, theFrameRect, flags, palette(), isEnabled(), text(), foregroundRole());
painter.restore();
}
To copy to clipboard, switch view to plain text mode
and alas, the text does not appear. If I change it to painter.scale(1.0, 1.0) the text draws just fine. I have a feeling that the scaling is putting the text outside of the frame rect so it is not drawing.
I tried setting the style with an explicit Qt::AlignRight, but it had no apparent effect (that is, it right justifies perfectly with a 1,1 scaling, but the text is still invisible with a -1,1 scaling).
Any ideas as to what I am doing wrong?
Bookmarks