PDA

View Full Version : QGLWidget crashes program when the window is resized rapidly



Lima
15th May 2016, 03:32
Hi there,

I've run into a strange bug, and I'm hoping someone here might have seen it before and can help me get past it. Basically, if I have a pyqt window with a QGLWidget, I get a "python has stopped working..." error when I resize the window rapidly. Curiously, it only happens if I resize via the corner, so height and width are changing at the same time. I know the qglwidget is the source of the problem because if I get rid of it, or just break the layout so it doesn't change size with the window, the problem goes away. I'm fairly sure it's not a code issue, but here's a simple example just to be sure:


import sys
from PyQt4 import QtCore, QtGui, QtOpenGL
from PyQt4.uic import loadUiType

Ui_MainWindow, QMainWindow = loadUiType('crashtest.ui')

class Main(QMainWindow, Ui_MainWindow):
def __init__(self):
super(Main, self).__init__()
self.setupUi(self)

self.glWidget = QtOpenGL.QGLWidget()
self.plotCanvas.addWidget(self.glWidget)

self.show()

def main():
app = QtGui.QApplication(sys.argv)
window = Main()

sys.exit(app.exec_())

if __name__ == "__main__":
main()

and the .ui file is basically just a main window with an empty vertical layout:


<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1051</width>
<height>529</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="2">
<layout class="QVBoxLayout" name="plotCanvas"/>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

I'm on windows 10 using python 3.5.1 and pyqt 4.11.4, from the latest anaconda distribution. I'm also using pyopengl 3.1.1 from this unofficial source (http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl) because the offical sources don't properly install glut on windows. Was pointed to that site by several different sources so I'm pretty sure it's reliable. I'm not sure how to debug this, so any advice along that line would be much appreciated. Thanks.

Apexdev
23rd May 2016, 16:19
Did you ever figure out the issue? I'm using PyQt5.5 with Python 2.7 and I'm having a similar issue. When I resize the QOpenGLWidget window, it crashes or slows down the painting quite a bit.

Lima
26th May 2016, 02:07
Did you ever figure out the issue? I'm using PyQt5.5 with Python 2.7 and I'm having a similar issue. When I resize the QOpenGLWidget window, it crashes or slows down the painting quite a bit.

Unfortunately not. I eventually got frustrated and made the window a fixed size. Would still very much like to know the solution if you have better luck than I did.