I want axis labels for a plot I\'m making, and naturally the y-axis label should be oriented vertically. I\'m pretty sure QwtPlot does this, but I\'m trying to
Here is a variant of Mostafa's implementation.
void VerticalLabel::paintEvent(QPaintEvent*)
{
QPainter painter(this);
// painter.translate(sizeHint().width(),0);
// painter.rotate(90);
painter.translate(0,sizeHint().height());
painter.rotate(270);
painter.drawText(QRect (QPoint(0,0),QLabel::sizeHint()),Qt::AlignCenter,text());
}
basically i have removed setPen and setBrush to preserve stylesheet and i have used an overload of drawText that uses the rect instead of point. This allows to have the '\n' inside the text or use WordWrap as a flag.