Skip to content

QFontDialog.getFont() returns results in different order in PyQt6 and PySide6 #528

@termim

Description

@termim

In QtPy-2.4.3 QFontDialog.getFont() returns tuple (font,bool) in PyQt6 and (bool, font) in PySide6:


import os

os.environ['QT_API'] = 'pyqt6'
#os.environ['QT_API'] = 'pyside6'

from qtpy import QtWidgets

def open_font_dialog():
   font, ok = QtWidgets.QFontDialog.getFont()
   if ok:
      print(f"{font=}")
      print(f"{ok=}")

app = QtWidgets.QApplication([])
button = QtWidgets.QPushButton("Select Font")
button.clicked.connect(open_font_dialog)
button.show()
app.exec()

"""
pyqt6:

font=<PyQt6.QtGui.QFont object at 0x7f5e54e04510>
ok=True


pyside6:

font=True
ok=<PySide6.QtGui.QFont(Droid Sans,12,-1,5,400,0,0,0,0,0,0,0,0,0,0,1,Regular) at 0x7f5d3fa00b40>
"""

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions