Fix error: 'width' is deprecated: Use QFontMetrics::horizontalAdvance.
This commit is contained in:
parent
0b7479ce98
commit
9e3e59d267
|
@ -39,7 +39,11 @@ void SetTabStopDistance(QPlainTextEdit *edit, int tabWidthChar)
|
|||
#else
|
||||
// compute the size of a char in double-precision
|
||||
static constexpr int bigNumber = 1000; // arbitrary big number.
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
const int many_char_width = fontMetrics.horizontalAdvance(testString.repeated(bigNumber));
|
||||
#else
|
||||
const int many_char_width = fontMetrics.width(testString.repeated(bigNumber));
|
||||
#endif
|
||||
const double singleCharWidthDouble = many_char_width / double(bigNumber);
|
||||
// set the tab stop with double precision
|
||||
edit->setTabStopDistance(tabWidthChar * singleCharWidthDouble);
|
||||
|
|
|
@ -501,7 +501,11 @@ void SetTabStopDistance(QPlainTextEdit *edit, int tabWidthChar)
|
|||
#else
|
||||
// compute the size of a char in double-precision
|
||||
static constexpr int bigNumber = 1000; // arbitrary big number.
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
const int many_char_width = fontMetrics.horizontalAdvance(testString.repeated(bigNumber));
|
||||
#else
|
||||
const int many_char_width = fontMetrics.width(testString.repeated(bigNumber));
|
||||
#endif
|
||||
const double singleCharWidthDouble = many_char_width / double(bigNumber);
|
||||
// set the tab stop with double precision
|
||||
edit->setTabStopDistance(tabWidthChar * singleCharWidthDouble);
|
||||
|
|
Loading…
Reference in New Issue
Block a user