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

Elvis Stansvik elvstone at gmail.com
Sat Feb 2 20:31:16 GMT 2019


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..?

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cppversion.png
Type: image/png
Size: 56987 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190202/d5063ffd/attachment-0001.png>


More information about the PyQt mailing list