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:08:12 +03:00
parent 1b3b7b0b29
commit 6554500593
13 changed files with 42 additions and 47 deletions
+2 -2
View File
@@ -148,7 +148,7 @@ char NetHackQtYnDialog::Exec()
q->setMargin(4);
vb->addWidget(q);
}
QGroupBox *group = new QGroupBox(bigq ? QString::null : qlabel, this);
QGroupBox *group = new QGroupBox(bigq ? QString() : qlabel, this);
vb->addWidget(group);
QHBoxLayout *groupbox = new QHBoxLayout();
group->setLayout(groupbox);
@@ -350,7 +350,7 @@ char NetHackQtYnDialog::Exec()
QPushButton cancel("Dismiss",this);
label.setFrameStyle(QFrame::Box|QFrame::Sunken);
label.setAlignment(Qt::AlignCenter);
label.resize(fontMetrics().width(qlabel)+60,30+fontMetrics().height());
label.resize(fontMetrics().horizontalAdvance(qlabel)+60,30+fontMetrics().height());
cancel.move(width()/2-cancel.width()/2,label.geometry().bottom()+8);
connect(&cancel,SIGNAL(clicked()),this,SLOT(reject()));
centerOnMain(this);