Hi,
I have created a custom label where text is compressed if wider than object; here the code:

Qt Code:
  1. void CustomLabel::paintEvent(QPaintEvent * /* event */)
  2. {
  3. QPainter *painter = new QPainter(this);
  4. painter->setRenderHints(QPainter::HighQualityAntialiasing,true);
  5. QAbstractTextDocumentLayout::PaintContext context;
  6. doc.setDefaultFont(font());
  7. doc.setHtml(text());
  8. float ratio = doc.documentLayout()->documentSize().width() / width();
  9. if(ratio > 1.0)
  10. painter->scale(1.0/ratio,1.0);
  11. doc.documentLayout()->draw(painter, context);
  12. delete painter;
  13. }
To copy to clipboard, switch view to plain text mode 

It works; but if I have 2 sided labels, one normal qlabel and one customlabel the text in the custom label has a base line which is lower; here a picture of what I mean: the three labels on the left are qlabels and those with bold text are customlabels



I have used Designer to create the gui and, from designer itself, I have promoted the labels to customlabel.

Has QLabel a property which returns text position or something else to adjust the text position in my label?

Thanks.