Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-3043

typing: QMessageBox static methods should support parent = None

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Fixed
    • Icon: Not Evaluated Not Evaluated
    • None
    • 6.8.2
    • Type hints
    • None

      The following static methods accept parent = None :

      • QMessageBox.information
      • QMessageBox.warning
      • QMessageBox.critical
      • QMessageBox.question

       

      Example code :
      QMessageBox.information(None, 'info', 'info')
      QMessageBox.warning(None, 'warning', 'warning')
      QMessageBox.critical(None, 'critical', 'critical')
      QMessageBox.question(None, 'question', 'question')
      QMessageBox.about(None, 'about', 'about')
      QMessageBox.aboutQt(None, 'aboutQt')
       

      It's not just a theorical issue. For example, I use QMessageBox.warning in my exception hook to display an better error message on Windows, but I don't have any QWidget instance at hand inside the exception hook.

       

      Reported from PySide6-stubs

      See full example : https://github.com/python-qt-tools/PySide6-stubs/blob/main/tests/qmessagebox.py

        1. example_with_qmessagebox.critical.py
          2 kB
          Philippe Fremy
        2. qmessagebox2.py
          0.8 kB
          Philippe Fremy
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            ctismer Christian Tismer
            bluebird75 Philippe Fremy
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes