Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. aboutQt() Runtime Error
Qt 6.11 is out! See what's new in the release blog

aboutQt() Runtime Error

Scheduled Pinned Locked Moved Solved Qt for Python
pysidepython
3 Posts 2 Posters 133 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SamuraiDestroy
    wrote last edited by
    #1

    I am trying to add an About Qt window to my Python Qt app but whenever the function to create it is triggered, it returns this error

        aboutQt.aboutQt(aboutQt)
    RuntimeError: libshiboken: Internal C++ object (PySide6.QtWidgets.QMessageBox) already deleted.
    

    Here is the relevant portion of my code:

    from PySide6 import QtCore, QtWidgets, QtGui
    from PySide6.QtUiTools import QUiLoader
    from PySide6.QtCore import QFile
    from ui.ui_mainWindow import Ui_MainWindow
    
    class mainWindow(QtWidgets.QMainWindow):
        def __init__(self):
            super(mainWindow, self).__init__()
            self.ui = Ui_MainWindow()
            self.ui.setupUi(self)
    
    class dialogWindow(QtWidgets.QDialog):
        def __init__(self, windowFile):
            super(dialogWindow, self).__init__()
            self.ui = windowFile
            self.ui.setupUi(self, self)
    
    def aboutQtWindow():
        global aboutQt
        aboutQt = QtWidgets.QMessageBox(dialogWindow(ui.ui_aboutQt.Ui_Dialog))
        aboutQt.aboutQt(aboutQt)
    
    if __name__ == "__main__":
        app = QtWidgets.QApplication(sys.argv)
        window = mainWindow()
        window.show()
    
        window.ui.actionAbout_Qt.triggered.connect(aboutQtWindow)
        sys.exit(app.exec())
    
    JonBJ 1 Reply Last reply
    0
    • S SamuraiDestroy

      I am trying to add an About Qt window to my Python Qt app but whenever the function to create it is triggered, it returns this error

          aboutQt.aboutQt(aboutQt)
      RuntimeError: libshiboken: Internal C++ object (PySide6.QtWidgets.QMessageBox) already deleted.
      

      Here is the relevant portion of my code:

      from PySide6 import QtCore, QtWidgets, QtGui
      from PySide6.QtUiTools import QUiLoader
      from PySide6.QtCore import QFile
      from ui.ui_mainWindow import Ui_MainWindow
      
      class mainWindow(QtWidgets.QMainWindow):
          def __init__(self):
              super(mainWindow, self).__init__()
              self.ui = Ui_MainWindow()
              self.ui.setupUi(self)
      
      class dialogWindow(QtWidgets.QDialog):
          def __init__(self, windowFile):
              super(dialogWindow, self).__init__()
              self.ui = windowFile
              self.ui.setupUi(self, self)
      
      def aboutQtWindow():
          global aboutQt
          aboutQt = QtWidgets.QMessageBox(dialogWindow(ui.ui_aboutQt.Ui_Dialog))
          aboutQt.aboutQt(aboutQt)
      
      if __name__ == "__main__":
          app = QtWidgets.QApplication(sys.argv)
          window = mainWindow()
          window.show()
      
          window.ui.actionAbout_Qt.triggered.connect(aboutQtWindow)
          sys.exit(app.exec())
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote last edited by JonB
      #2

      @SamuraiDestroy
      I believe you will find:

      aboutQt = QtWidgets.QMessageBox(dialogWindow(ui.ui_aboutQt.Ui_Dialog))
      

      creates an anonymous QDialog temporarily, makes the QMessageBox have that to center on, and then destroys the QDialog so the message box now is to be centered on a non-existent dialog? Might cause the message?

      aboutQt.aboutQt(aboutQt)
      

      don't know what this would do, seems to pass aboutQt to center on itself? Might cause the message?

      The method is static aboutQt(parent[, title=""]). So it's static, and I believe it creates and displays the whole "About" dialog. Don't know what your intention to create your own about dialog is about? (If you want to display some dialog of your own as the parent for the aboutQt message box you need to create and show that dialog and keep a reference to it.)

      I thought you were just supposed to write something like:

      QtWidgets.QMessageBox.aboutQt(None)
      

      No instances of anything. No dialog of your own.

      To center that on the main window, if you want that, you would pass your window = mainWindow() instance as parent.

      P.S.
      I see there is also a convenience QApplication.aboutQt() method. So app.aboutQt() should also work.

      S 1 Reply Last reply
      2
      • S SamuraiDestroy has marked this topic as solved
      • JonBJ JonB

        @SamuraiDestroy
        I believe you will find:

        aboutQt = QtWidgets.QMessageBox(dialogWindow(ui.ui_aboutQt.Ui_Dialog))
        

        creates an anonymous QDialog temporarily, makes the QMessageBox have that to center on, and then destroys the QDialog so the message box now is to be centered on a non-existent dialog? Might cause the message?

        aboutQt.aboutQt(aboutQt)
        

        don't know what this would do, seems to pass aboutQt to center on itself? Might cause the message?

        The method is static aboutQt(parent[, title=""]). So it's static, and I believe it creates and displays the whole "About" dialog. Don't know what your intention to create your own about dialog is about? (If you want to display some dialog of your own as the parent for the aboutQt message box you need to create and show that dialog and keep a reference to it.)

        I thought you were just supposed to write something like:

        QtWidgets.QMessageBox.aboutQt(None)
        

        No instances of anything. No dialog of your own.

        To center that on the main window, if you want that, you would pass your window = mainWindow() instance as parent.

        P.S.
        I see there is also a convenience QApplication.aboutQt() method. So app.aboutQt() should also work.

        S Offline
        S Offline
        SamuraiDestroy
        wrote last edited by
        #3

        @JonB said in aboutQt() Runtime Error:

        I thought you were just supposed to write something like:

        QtWidgets.QMessageBox.aboutQt(None)

        This works perfectly, thank you

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved