PDA

View Full Version : QCalendarWidget and QGraphicsBlurEffect



googie
22nd October 2013, 13:43
There's a problem with setting blur effect for QCalendarWidget. It's like the calendar doesn't repaint correctly its contents. I set the effect to enabled, but the widget doesn't get blured, but then when I resize the widget, it kind of gets blured, but not really (only some parts and only at some moments).

I tried it under linux and windows with very simple test application:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QGraphicsBlurEffect>
#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();

private slots:
void on_checkBox_toggled(bool checked);

private:
Ui::MainWindow *ui;
QGraphicsBlurEffect* effect;
};

#endif // MAINWINDOW_H


#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);

effect = new QGraphicsBlurEffect();
effect->setEnabled(false);

ui->calendarWidget->setGraphicsEffect(effect);
}

MainWindow::~MainWindow()
{
delete effect;
delete ui;
}

void MainWindow::on_checkBox_toggled(bool checked)
{
effect->setEnabled(checked);
}


<?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>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item>
<widget class="QCalendarWidget" name="calendarWidget"/>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

Am I doing something wrong, or is it a bug?

stampede
22nd October 2013, 15:36
After checking the check box, widget borders get a small blur, but if you resize the window, some internals of the calendar (month & day strings in selection boxes) are totally blured, that you can't even read those strings anymore.
I don't know if its a bug or not, but certainly I don't like it:)
This

effect->setBlurHints(QGraphicsBlurEffect::QualityHint);
doesn't really help.
I have tested with and without desktop composition, no difference.

maybe relevant:
https://bugreports.qt-project.org/browse/QTBUG-14621
http://blog.qt.digia.com/blog/2009/09/15/using-blur-behind-on-windows/

Tested on:
Windows 8 64 bit
Qt 4.7.3, gcc 4.5.2
Qt 5.1.0, gcc 4.7.2

btw. what result are you trying to get ? maybe second link can help you if you are trying to get a simple background blur

googie
22nd October 2013, 15:46
btw. what result are you trying to get ? maybe second link can help you if you are trying to get a simple background blur
I was playing with various visual methods to mark some widgets disabled.

This works just fine for virtually any other widget (from QtWidgets), but not for this one. I know that custom 3rd party widgets have such problems too and it seems to be due to invalid painting order in the widget's internals. I guess that's what's wrong with the QWidgetCalendar as well.

The bug report you mentioned is not really related. It's about the background and I'm all about the foreground, the face of the widget that has the effect set on.