@Pl45m4 In this function I am painting on axis->labelPix which is a QPixmap. The axis->labelPix is then put in its correct position using QPainter in the paintEvent() of PlotWidget.
@VRonin said in Number of characters that fit into given width:
Something like http://doc.qt.io/qt-5/qfontmetrics.html#elidedText ?
Turns out it will not work for me.
The QString returned includes the ellipsis and there is no way to avoid them, because passing Qt::ElideNone means "do not truncate" instead of "omit the ellipsis" (as I feared).
Isn't any modern C++ compiler capable of doing that optimization implicitly (with optimizations enabled)?
In all probability, yes; it's just a stupid habit. Compilers weren't so smart before, but they are improving by the minute. You can safely replace it with left.height() / 2.