standarddialogs example: Fix font handling
The example crashed since it passed the font label text (which receives the font key) to the QFont constructor taking the family list. Use QFont::fromString() instead. Change-Id: I499fc9200b4d817b10c946a7b79ede4e7f7e69af Reviewed-by: Andy Shaw <andy.shaw@qt.io> (cherry picked from commit c10159a9a1254992867242897adb19ae1c3c3c35) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
65760c077d
commit
35e6ef6395
@ -388,8 +388,14 @@ void Dialog::setColor()
|
|||||||
void Dialog::setFont()
|
void Dialog::setFont()
|
||||||
{
|
{
|
||||||
const QFontDialog::FontDialogOptions options = QFlag(fontDialogOptionsWidget->value());
|
const QFontDialog::FontDialogOptions options = QFlag(fontDialogOptionsWidget->value());
|
||||||
|
|
||||||
|
const QString &description = fontLabel->text();
|
||||||
|
QFont defaultFont;
|
||||||
|
if (!description.isEmpty())
|
||||||
|
defaultFont.fromString(description);
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
QFont font = QFontDialog::getFont(&ok, QFont(fontLabel->text()), this, "Select Font", options);
|
QFont font = QFontDialog::getFont(&ok, defaultFont, this, "Select Font", options);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
fontLabel->setText(font.key());
|
fontLabel->setText(font.key());
|
||||||
fontLabel->setFont(font);
|
fontLabel->setFont(font);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user