summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-10-19 11:39:24 +0200
committerAndy Shaw <andy.shaw@qt.io>2020-11-20 14:30:22 +0100
commitd8602ce58b6ef268be84b9aa0166b0c3fa6a96e8 (patch)
tree3665176e38aac64015213085f3d0e867ec11e612 /tests/auto/widgets
parent13c460d0ff1a4eecfb7b1bc43a863783ed59a2bd (diff)
QFont: Prefer setFamilies() over setFamily()
By depending on setFamilies() then we can be sure that font names with spaces, commas, quotes and so on are correctly handled without being misinterpreted. For now it will split on the comma when a string containing one is passed to setFamily. But from Qt 6.2 this will be removed to preserve the family string as a convenience function. [ChangeLog][QtGui][QFont] Indicated that setFamilies/families is preferred over setFamily/family to ensure that font family names are preserved when spaces, commas and so on are used in the name. Change-Id: Id3c1a4e827756a4c928fed461a4aafa5a0f06633 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp
index 1f06c537c6..0d95102f66 100644
--- a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp
+++ b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp
@@ -91,7 +91,7 @@ void tst_QFontComboBox::currentFont_data()
// Normalize the names
QFont defaultFont;
QFontInfo fi(defaultFont);
- defaultFont = QFont(fi.family()); // make sure we have a real font name and not something like 'Sans Serif'.
+ defaultFont = QFont(QStringList{fi.family()}); // make sure we have a real font name and not something like 'Sans Serif'.
if (!QFontDatabase::isPrivateFamily(defaultFont.family()))
QTest::newRow("default") << defaultFont;
defaultFont.setPointSize(defaultFont.pointSize() + 10);
@@ -99,8 +99,8 @@ void tst_QFontComboBox::currentFont_data()
QTest::newRow("default2") << defaultFont;
QStringList list = QFontDatabase::families();
for (int i = 0; i < list.count(); ++i) {
- QFont f = QFont(QFontInfo(QFont(list.at(i))).family());
- if (!QFontDatabase::isPrivateFamily(f.family()))
+ QFont f = QFont(QStringList{QFontInfo(QFont(list.at(i))).family()});
+ if (!QFontDatabase::isPrivateFamily(f.families().first()))
QTest::newRow(qPrintable(list.at(i))) << f;
}
}