Skip to content

Replaced QFontMetrics::horizontalAdvance() method by QFontMetrics::boundingRect().width()

Arthur AM requested to merge telekid/rocs:master into master

Starting with Qt5.11, the function QFontMetrics::width() became deprecated. This method was used to calculate a example character width for the Side Tool Button on the Side Dock Widget. To substitute the obsolete function, the function QFontMetrics::horizontalAdvance() was used. I propose to replace the QFontMetrics::horizontalAdvance(QChar ch) with the function QFontMetrics::boundingRect().width(). The reason is that horizontalAdvance() only works for Qt5.11 or newer versions, while the proposed method works for older versions as well, while performing the same task for our purposes. After testing both methods, the proposed one actually created a Side Tool Button with more relief spacing between characters and thus facilitated reading. Currently, some operating systems, like Ubuntu 18.04 LTS, provided Qt5.9 as default version. The modification proposed lets the users use Rocs with Qt5.9 without breaking.

References:

QFontMetrics::width()

QFontMetrics::boundingRect()

About deprecation of QFontMetrics::width()

Edited by Arthur AM

Merge request reports