- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 159
 
Open
Labels
Milestone
Description
To make up mightBeRichText, QtGui is being imported in the following lines:
Lines 103 to 112 in b851e00
| # Missing QtGui utility functions on Qt | |
| if getattr(Qt, "mightBeRichText", None) is None: | |
| try: | |
| from PySide2.QtGui import Qt as guiQt | |
| Qt.mightBeRichText = guiQt.mightBeRichText | |
| del guiQt | |
| except ImportError: | |
| # Fails with PySide2 5.12.0 | |
| pass | 
Lines 132 to 137 in b851e00
| # Missing QtGui utility functions on Qt | |
| if getattr(Qt, "mightBeRichText", None) is None: | |
| from PySide6.QtGui import Qt as guiQt | |
| Qt.mightBeRichText = guiQt.mightBeRichText | |
| del guiQt | 
I suppose the function is not something widely used, so the imports slow the module initiating down.
I'd implement the function this way (and similarly for PySide2):
    # Missing QtGui utility functions on Qt
    if not hasattr(Qt, "mightBeRichText"):
        def _mightBeRichText(*args, **kwargs):
            from PySide6.QtGui import Qt as guiQt
            return guiQt.mightBeRichText(*args, **kwargs)
        Qt.mightBeRichText = _mightBeRichTextFurthermore, this seems to bypass PYSIDE-2898.
But then, what about convertFromPlainText, which is also defined in QtGui.Qt?