Python Exit Code -1073741819 (0xC0000005) When Using PyQT5

-3

I'm trying to use PyQT5 to generate a scrollable window for my graph that I'm generating however, everytime it's generated, I get the error: -1073741819 (0xC0000005) and it ends my program execution.

The code for the window is:

class ScrollableWindow(QtWidgets.QMainWindow):
def __init__(self, fig):
    self.qapp = QtWidgets.QApplication([])

    QtWidgets.QMainWindow.__init__(self)
    self.widget = QtWidgets.QWidget()
    self.setCentralWidget(self.widget)
    self.widget.setLayout(QtWidgets.QVBoxLayout())
    self.widget.layout().setContentsMargins(0,0,0,0)
    self.widget.layout().setSpacing(0)

    self.fig = fig
    self.canvas = FigureCanvas(self.fig)
    self.canvas.draw()
    self.scroll = QtWidgets.QScrollArea(self.widget)
    self.scroll.setWidget(self.canvas)

    self.nav = NavigationToolbar(self.canvas, self.widget)
    self.widget.layout().addWidget(self.nav)
    self.widget.layout().addWidget(self.scroll)

    self.show()
    exit(self.qapp.exec_())

And I'm calling it as (fund_figs is the graph name):

a = ScrollableWindow(fund_figs)
print(a)

Any help is appreciated.

python
pyqt
asked on Stack Overflow May 17, 2021 by Keelan • edited May 17, 2021 by Keelan

2 Answers

0

I'm not great with this side of Python, but here are two things I noticed that may help:

  • Make sure to correct your indentation
  • Make sure to run import QtWidgets

If you don't want the error to end your program, try doing this:

    class ScrollableWindow(QtWidgets.QMainWindow):
    def __init__(self, fig):
         try:
              #enter code here
         except Exception as e:
              print("Here is the error: {} " .format(e))

I don't know if this helped at all, sorry if it didn't, but I do hope it educated you in some form or another.

answered on Stack Overflow May 17, 2021 by Maxgoodman07
-1

It was an issue with PyQT5 which when generating a window before it, closing it and generating a scrollable window causes the program to crash.

Basically, there was another scatter plot before it which closes before the one in question is generated. It caused the program to crash, I'm assuming its some kind of bug.

answered on Stack Overflow May 17, 2021 by Keelan • edited May 18, 2021 by Bhargav Rao

User contributions licensed under CC BY-SA 3.0