tynn
tynn

Reputation: 39853

QGraphicsBlurEffect resizes Text but not Widget itself

I'm trying to use Qt 5.5.1 QGraphicsBlurEffect in my project, but can't make it work on Mac:

screenshot on mac

I was trying to make a change by using PerformanceHint, QualityHint or AnimationHint, but didn't succeed. Using QGraphicsColorizeEffect I had the same issue, while QGraphicsOpacityEffect and QGraphicsDropShadowEffect, as well as everything on Linux worked perfectly fine:

enter image description here

How can I change my project file or code to make this graphics issue go away? Is it even possible?

TEMPLATE = app
TARGET = main
QT += widgets
SOURCES += main.cpp

#include <QtWidgets>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QMainWindow window;

    QTextEdit *text = new QTextEdit;
    text->setReadOnly(true);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(text);

    QWidget *widget = new QWidget;
    widget->setLayout(layout);

    QGraphicsBlurEffect effect;
    effect.setBlurRadius(3);

    QLabel *test = new QLabel("TEST");
    test->setGraphicsEffect(&effect);
    (new QHBoxLayout(text))->addWidget(test, 0, Qt::AlignCenter);

    window.setCentralWidget(widget);
    window.show();
    return app.exec();
}

Upvotes: 1

Views: 324

Answers (1)

adequate allactaga
adequate allactaga

Reputation: 21

I had a similar problem with QGraphicsOpacityEffect: blurred text and icons when it must be crisp sharp. Seems like a bug in Qt. My solution was to write my own small class containing everything I need with a proper rendering. Well, you can try to fix Qt... good luck at reading source code of graphics effects. It is quite complicated with all it's dpr and transform matrix and rendering child widgets.

Upvotes: 1

Related Questions