Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Is there a way to get the horizonal advance of every character in a string?
I'm looking for something like GetPartialTextExtents() in wxWidgets or GDI+ MeasureCharacterRanges(). Does QT have something like that? QFontMetrics doesn't seem to.
What's wrong with QFontMetrics::horizontalAdvance(QChar ch) ?
@Christian-Ehrlicher Nothing, except that I'm calling it over 600,000 times.
When I switched from individual character measuring to string measuring (getting each characters width) in wxWidgets, I got a 10x speed improvement.
Nothing, except that I'm calling it over 600,000 times.
If you really need it then add a cache.
Just as a note
There is an overload that takes a QString
int horizontalAdvance(const QString &, int len = -1) const;
However, if that is faster then looping the string your self and call the QChar version i don't know.
Actually, 100% my fault. Things are plenty fast. I had an extra call to size() in my method that I didn't need, and that is a slow call.