Qt: deprecation warnings, again

Check Qt version for the QFontMetrics::width vs horizontalAdvance.
Of course can't just #define horizontalAdvance to width, that would
be too easy ...
This commit is contained in:
Pasi Kallinen
2021-08-15 10:58:39 +03:00
parent 29aca6276e
commit 98ec66e00c
7 changed files with 22 additions and 13 deletions

View File

@@ -80,8 +80,8 @@ bool NetHackQtStringRequestor::Get(char *buffer, int maxchar, int minchar)
input.setMaxLength(maxchar - 1);
const QString &txt = prompt.text();
int pw = fontMetrics().horizontalAdvance(txt),
ww = minchar * input.fontMetrics().horizontalAdvance(QChar('X'));
int pw = fontMetrics().QFM_WIDTH(txt),
ww = minchar * input.fontMetrics().QFM_WIDTH(QChar('X'));
int heightfactor = ((txt.size() > 16) ? 3 : 2) * 2; // 2 or 3 lines high
int widthfudge = (((txt.size() > 16) ? 1 : 2) * 5) * 2; // 5: margn, guttr
resize(pw + ww + widthfudge, fontMetrics().height() * heightfactor);