[PyQt] Resize flicking on QMainWindow centralWidget in python but not C++

Patrick Stinson patrickkidd at gmail.com
Thu Oct 10 14:35:26 BST 2019


Looks like this is just a function of QQuickWidget, either in a layout or standalone:

    app = QApplication(sys.argv)
    mw = QWidget()
    w = QQuickWidget()
    Layout = QVBoxLayout(mw)
    Layout.addWidget(w)
    mw.show()
    app.exec()


    app = QApplication(sys.argv)
    mw = QQuickWidget()
    mw.show()
    app.exec()

> On Oct 10, 2019, at 9:29 AM, Patrick Stinson <patrickkidd at gmail.com> wrote:
> 
> Turns out simply adding a QQuickWidget as a child to QMainWindow::centralWidget causes this problem. I imagine this is because of the OpenGL buffer in QtQuick:
> 
>     app = QApplication(sys.argv)
>     mw = QMainWindow()
>     w = QQuickWidget()
>     mw.setCentralWidget(w)
>     mw.show()
>     app.exec()
> 
> Does anyone know of a workaround for this? It makes the app look so ugly!
> 
>> On Oct 7, 2019, at 2:10 PM, Eric Pettersen <pett at cgl.ucsf.edu <mailto:pett at cgl.ucsf.edu>> wrote:
>> 
>> We had this behavior in our own app, but it kind of went away on its own.  We came to suspect that it had to with the setting of MACOSX_DEPLOYMENT_TARGET.  I don’t know if you set that variable in your compile, but if you do you might try changing it (or not setting it) and see what happens.
>> 
>> —Eric
>> 
>>> On Oct 6, 2019, at 1:38 PM, Patrick Stinson <patrickkidd at gmail.com <mailto:patrickkidd at gmail.com>> wrote:
>>> 
>>> I wonder if maybe the use of QQuickWidget child widgets enables some kind of OpenGL buffer in the QMainWindoe?
>>> 
>>>> On Oct 6, 2019, at 12:25 AM, Patrick Stinson <patrickkidd at gmail.com <mailto:patrickkidd at gmail.com>> wrote:
>>>> 
>>>> I put a qDebug() line in QMainWindow() and QOpenGLWidget(), rebuilt/installed Qt, and ran my app. I saw the line for the QMainWindow() but not QOpenGLWidget(), so that means QOpenGLWidget isn’t being run in my app. But I am still seeing the problem. Difficult to pinpoint as a reproducible report.
>>>> 
>>>>> On Oct 5, 2019, at 10:25 PM, Patrick Stinson <patrickkidd at gmail.com <mailto:patrickkidd at gmail.com>> wrote:
>>>>> 
>>>>> So it does, and changing that makes it work like the C++ example.
>>>>> 
>>>>> My own app is still showing the problem even without using QOpenGLWidget. I wonder if there is some setting somewhere that implicitly uses QOpenGLWidget….
>>>>> 
>>>>>> On Oct 5, 2019, at 5:36 PM, Eric Pettersen <pett at cgl.ucsf.edu <mailto:pett at cgl.ucsf.edu>> wrote:
>>>>>> 
>>>>>> Your Python class inherits from QOpenGLWidget.  Your C++ class inherits from QWidget.
>>>>>> 
>>>>>>> On Oct 5, 2019, at 2:10 PM, Patrick Stinson <patrickkidd at gmail.com <mailto:patrickkidd at gmail.com>> wrote:
>>>>>>> 
>>>>>>> Hello,
>>>>>>> 
>>>>>>> On MacOS, a QMainWindow with a simple painted centralWidget flickers when resizing quickly in python but not in C++. This only occurs with QMainWindow It is particularly pronounced more complex widgets, as shown in the following video:
>>>>>>> 
>>>>>>> https://youtu.be/0Qjy2wm6m9M <https://youtu.be/0Qjy2wm6m9M>
>>>>>>> 
>>>>>>> Here is the python example that shows the bug. Just run, rapidly resize the height of the widget , and observe a black flickering on the top edge of the widget as the height changes.
>>>>>>> 
>>>>>>> class Widget(QOpenGLWidget):
>>>>>>>     def paintEvent(self, e):
>>>>>>>         p = QPainter(self)
>>>>>>>         p.setBrush(Qt.red)
>>>>>>>         p.drawRect(self.rect())
>>>>>>> 
>>>>>>> app = QApplication(sys.argv)
>>>>>>> mw = QMainWindow()
>>>>>>> w = Widget()
>>>>>>> mw.setCentralWidget(w)
>>>>>>> mw.show()
>>>>>>> w.show()
>>>>>>> app.exec()
>>>>>>> 
>>>>>>> 
>>>>>>> The following 1-to-1 C++ translation shows no such behavior:
>>>>>>> 
>>>>>>> 
>>>>>>> #include <QApplication>
>>>>>>> #include <QMainWindow>
>>>>>>> #include <QWidget>
>>>>>>> #include <QPainter>
>>>>>>> 
>>>>>>> class Widget : public QWidget {
>>>>>>> public:
>>>>>>>     void paintEvent(QPaintEvent *) {
>>>>>>>         QPainter p(this);
>>>>>>>         p.setBrush(Qt::red);
>>>>>>>         p.drawRect(rect());
>>>>>>>     }
>>>>>>> };
>>>>>>> 
>>>>>>> int main(int argc, char *argv[])
>>>>>>> {
>>>>>>>     QApplication a(argc, argv);
>>>>>>>     QMainWindow mw;
>>>>>>>     QWidget *w = new Widget;
>>>>>>>     mw.setCentralWidget(w);
>>>>>>>     mw.show();
>>>>>>>     return a.exec();
>>>>>>> }
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> _______________________________________________
>>>>>>> PyQt mailing list    PyQt at riverbankcomputing.com <mailto:PyQt at riverbankcomputing.com>
>>>>>>> https://www.riverbankcomputing.com/mailman/listinfo/pyqt <https://www.riverbankcomputing.com/mailman/listinfo/pyqt>
>>>>>> 
>>>>> 
>>>> 
>>> _______________________________________________
>>> PyQt mailing list    PyQt at riverbankcomputing.com <mailto:PyQt at riverbankcomputing.com>
>>> https://www.riverbankcomputing.com/mailman/listinfo/pyqt <https://www.riverbankcomputing.com/mailman/listinfo/pyqt>
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20191010/97d7a419/attachment-0001.html>


More information about the PyQt mailing list