Created
March 13, 2024 13:34
-
-
Save ShenTengTu/7e35a5b92b299b057139aee37cd27b51 to your computer and use it in GitHub Desktop.
[Python] Qt: Function with overloaded type hints, equivalent to "QItemEditorFactory.defaultFactory().createEditor"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@overload | |
def defaultEditorFactory(arg: Type[bool], parent: QWidget) -> QComboBox: ... | |
@overload | |
def defaultEditorFactory(arg: Type[float], parent: QWidget) -> QDoubleSpinBox: ... | |
@overload | |
def defaultEditorFactory(arg: Type[int], parent: QWidget) -> QSpinBox: ... | |
@overload | |
def defaultEditorFactory(arg: Type[QDate], parent: QWidget) -> QDateEdit: ... | |
@overload | |
def defaultEditorFactory(arg: Type[QDateTime], parent: QWidget) -> QDateTimeEdit: ... | |
@overload | |
def defaultEditorFactory(arg: Type[QPixmap], parent: QWidget) -> QLabel: ... | |
@overload | |
def defaultEditorFactory(arg: Type[str], parent: QWidget) -> QLineEdit: ... | |
@overload | |
def defaultEditorFactory(arg: Type[QTime], parent: QWidget) -> QTimeEdit: ... | |
@overload | |
def defaultEditorFactory(arg: type, parent: QWidget) -> QWidget: ... | |
def defaultEditorFactory(arg, parent): | |
from qtpy.QtCore import QMetaType | |
from qtpy.QtWidgets import QItemEditorFactory | |
return QItemEditorFactory.defaultFactory().createEditor(QMetaType(arg).id(), parent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment