[PyQt] Huge text under macOS as soon as QGLWidget is used?

Elvis Stansvik elvstone at gmail.com
Sat Feb 2 20:37:55 GMT 2019


Den lör 2 feb. 2019 kl 21:31 skrev Elvis Stansvik <elvstone at gmail.com>:
>
> Den lör 2 feb. 2019 kl 21:12 skrev Elvis Stansvik <elvstone at gmail.com>:
> >
> > Hi all,
> >
> > (This may not be PyQt-specific.)
>
> Actually, I just tried in C++:
>
> #include <QApplication>
> #include <QMainWindow>
> #include <QPushButton>
> #include <QGLWidget>
> #include <QVBoxLayout>
>
> int main(int argc, char *argv[]) {
>     QApplication app(argc, argv);
>
>     // Case 1: No QGLWidget
>     QMainWindow win1;
>     auto *widget1 = new QWidget();
>     auto *layout1 = new QVBoxLayout();
>     layout1->addWidget(new QPushButton("Hello 1"));
>     widget1->setLayout(layout1);
>     win1.setCentralWidget(widget1);
>     win1.show();
>
>     // Case 2: QGLWidget
>     QMainWindow win2;
>     auto *widget2 = new QWidget();
>     auto *layout2 = new QVBoxLayout();
>     layout2->addWidget(new QPushButton("Hello 2"));
>     layout2->addWidget(new QGLWidget());
>     widget2->setLayout(layout2);
>     win2.setCentralWidget(widget2);
>     win2.show();
>
>     return app.exec();
> }
>
> And the result looks correct then (see attached screenshot).
>
> So it must be something with the fact that it's PyQt I think..?

For full disclosure: The C++ version I ran with Qt 5.12.0 while the
PyQt version was run with PyQt 5.11.3 (so Qt 5.11.2) and it's of
course possible it was a bug in Qt that is fixed in 5.12.0.

But something as obvious as this does not feel like it would be a Qt
bug, or everyone using QGLWidget on Mac would see it..

Elvis

>
> Elvis
>
> >
> > I was debugging a problem with huge text when mixing PyQt and VTK.
> >
> > Minimal test case:
> >
> > import sys
> >
> > from PyQt5.QtWidgets import QApplication, QMainWindow, \
> >         QPushButton, QVBoxLayout, QWidget
> > from PyQt5.QtOpenGL import QGLWidget
> >
> > app = QApplication(sys.argv)
> >
> > # Case 1: No QGLWidget
> > win1 = QMainWindow()
> > widget1 = QWidget()
> > layout1 = QVBoxLayout()
> > layout1.addWidget(QPushButton('Hello 1'))
> > widget1.setLayout(layout1)
> > win1.setCentralWidget(widget1)
> > win1.show()
> >
> > # Case 2: QGLWidget
> > win2 = QMainWindow()
> > widget2 = QWidget()
> > layout2 = QVBoxLayout()
> > layout2.addWidget(QPushButton('Hello 2'))
> > layout2.addWidget(QGLWidget())
> > widget2.setLayout(layout2)
> > win2.setCentralWidget(widget2)
> > win2.show()
> >
> > exit(app.exec_())
> >
> > See attached screenshot for result (using latest PyQt wheel from PyPI).
> >
> > How come in the second main window, the QPushButton has become huge,
> > just because a QGLWidget was added. Anyone know?
> >
> > Many thanks in advance,
> > Elvis


More information about the PyQt mailing list