Qt: Fix Qt5 deprecation warnings

Mostly the warnings were about QString::sprintf and QFontMetrics::width.
sprintf replacement is asprintf, which annoyingly behaves differently
from sprintf - it seems to append to the string.

Not thoroughly tested, but seems to work.
This commit is contained in:
Pasi Kallinen
2021-08-14 21:03:13 +03:00
parent 1b3b7b0b29
commit 6554500593
13 changed files with 42 additions and 47 deletions

View File

@@ -458,8 +458,7 @@ aboutMsg()
*p = '\0';
/* it's also long; break it into two pieces */
(void) strsubst(vbuf, " - ", "\n- ");
QString msg;
msg.sprintf(
QString msg = QString::asprintf(
// format
"NetHack-Qt is a version of NetHack built using" // no newline
#ifdef KDE
@@ -1022,8 +1021,7 @@ void NetHackQtMainWindow::doQuit(bool)
// nethack's #quit command itself) but this routine is unconditional
// in case someone wants to change that
#ifdef MACOS
QString info;
info.sprintf("This will end your NetHack session.%s",
QString info = QString::asprintf("This will end your NetHack session.%s",
!g.program_state.something_worth_saving ? ""
: "\n(Cancel quitting and use the Save command"
"\nto save your current game.)");