aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-10-12 08:27:44 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-10-12 13:54:23 +0000
commit706fc86ac231208894ff7e2e8b26bfe596f55a45 (patch)
tree41174237ca25b875193eb714818531529f76fcfe
parentd49ab9644f0881b43035b528ed3e1099b839fa32 (diff)
PySide6: Fix constructing a QFont from a family string
Change qtbase/d8602ce58b6ef268be84b9aa0166b0c3fa6a96e8 added QFont(QStringList) which now triggers for strings as well since they are a sequence. Fix by specifying overload numbers. Fixes: PYSIDE-1685 Change-Id: Ic78c2b273fe81949f852ea6e0f578613bc0a623a Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit 0c4b73611801c788849f0bcf93737c670b61ee03) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml3
-rw-r--r--sources/pyside6/tests/QtGui/CMakeLists.txt1
-rw-r--r--sources/pyside6/tests/QtGui/qfont_test.py60
3 files changed, 64 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml b/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml
index 275359ff8..a22e9c85c 100644
--- a/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml
+++ b/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml
@@ -690,6 +690,9 @@
<extra-includes>
<include file-name="QStringList" location="global"/>
</extra-includes>
+ <!-- PYSIDE-1685: QFont(QString) should be checked first, else it will be interpreted as sequence -->
+ <modify-function signature="QFont(const QString&amp;,int,int, bool)" overload-number="0"/>
+ <modify-function signature="QFont(const QStringList &amp;,int,int, bool)" overload-number="1"/>
<modify-function signature="setStyleHint(QFont::StyleHint,QFont::StyleStrategy)">
<modify-argument index="2">
<rename to="strategy"/>
diff --git a/sources/pyside6/tests/QtGui/CMakeLists.txt b/sources/pyside6/tests/QtGui/CMakeLists.txt
index 179e88fd6..dc3056643 100644
--- a/sources/pyside6/tests/QtGui/CMakeLists.txt
+++ b/sources/pyside6/tests/QtGui/CMakeLists.txt
@@ -22,6 +22,7 @@ PYSIDE_TEST(qcolor_reduce_test.py)
PYSIDE_TEST(qcursor_test.py)
PYSIDE_TEST(qdatastream_gui_operators_test.py)
PYSIDE_TEST(qdesktopservices_test.py)
+PYSIDE_TEST(qfont_test.py)
PYSIDE_TEST(qfontmetrics_test.py)
PYSIDE_TEST(qguiapplication_test.py)
PYSIDE_TEST(qicon_test.py)
diff --git a/sources/pyside6/tests/QtGui/qfont_test.py b/sources/pyside6/tests/QtGui/qfont_test.py
new file mode 100644
index 000000000..131992b52
--- /dev/null
+++ b/sources/pyside6/tests/QtGui/qfont_test.py
@@ -0,0 +1,60 @@
+#############################################################################
+##
+## Copyright (C) 2021 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from PySide6.QtGui import QFont
+from helper.usesqapplication import UsesQApplication
+
+
+class QFontTest(UsesQApplication):
+
+ def testStringConstruction(self):
+ """PYSIDE-1685: Test that passing str to QFont works after addding
+ QFont(QStringList) by qtbase/d8602ce58b6ef268be84b9aa0166b0c3fa6a96e8"""
+ font_name = 'Times Roman'
+ font = QFont(font_name)
+ families = font.families()
+ self.assertEqual(len(families), 1)
+ self.assertEqual(families[0], font_name)
+
+ font = QFont([font_name])
+ families = font.families()
+ self.assertEqual(len(families), 1)
+ self.assertEqual(families[0], font_name)
+
+
+if __name__ == '__main__':
+ unittest.main()