Results 1 to 3 of 3

Thread: QCalendarWidget and QGraphicsBlurEffect

  1. #1
    Join Date
    Sep 2009
    Location
    Poland, Cracow
    Posts
    34
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QCalendarWidget and QGraphicsBlurEffect

    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:
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QGraphicsBlurEffect>
    5. #include <QMainWindow>
    6.  
    7. namespace Ui {
    8. class MainWindow;
    9. }
    10.  
    11. class MainWindow : public QMainWindow
    12. {
    13. Q_OBJECT
    14.  
    15. public:
    16. explicit MainWindow(QWidget *parent = 0);
    17. ~MainWindow();
    18.  
    19. private slots:
    20. void on_checkBox_toggled(bool checked);
    21.  
    22. private:
    23. Ui::MainWindow *ui;
    24. QGraphicsBlurEffect* effect;
    25. };
    26.  
    27. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow)
    7. {
    8. ui->setupUi(this);
    9.  
    10. effect = new QGraphicsBlurEffect();
    11. effect->setEnabled(false);
    12.  
    13. ui->calendarWidget->setGraphicsEffect(effect);
    14. }
    15.  
    16. MainWindow::~MainWindow()
    17. {
    18. delete effect;
    19. delete ui;
    20. }
    21.  
    22. void MainWindow::on_checkBox_toggled(bool checked)
    23. {
    24. effect->setEnabled(checked);
    25. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <ui version="4.0">
    3. <class>MainWindow</class>
    4. <widget class="QMainWindow" name="MainWindow">
    5. <property name="geometry">
    6. <rect>
    7. <x>0</x>
    8. <y>0</y>
    9. <width>400</width>
    10. <height>300</height>
    11. </rect>
    12. </property>
    13. <property name="windowTitle">
    14. <string>MainWindow</string>
    15. </property>
    16. <widget class="QWidget" name="centralWidget">
    17. <layout class="QVBoxLayout" name="verticalLayout">
    18. <item>
    19. <widget class="QCheckBox" name="checkBox">
    20. <property name="text">
    21. <string>CheckBox</string>
    22. </property>
    23. </widget>
    24. </item>
    25. <item>
    26. <widget class="QCalendarWidget" name="calendarWidget"/>
    27. </item>
    28. </layout>
    29. </widget>
    30. <widget class="QMenuBar" name="menuBar">
    31. <property name="geometry">
    32. <rect>
    33. <x>0</x>
    34. <y>0</y>
    35. <width>400</width>
    36. <height>21</height>
    37. </rect>
    38. </property>
    39. </widget>
    40. <widget class="QToolBar" name="mainToolBar">
    41. <attribute name="toolBarArea">
    42. <enum>TopToolBarArea</enum>
    43. </attribute>
    44. <attribute name="toolBarBreak">
    45. <bool>false</bool>
    46. </attribute>
    47. </widget>
    48. <widget class="QStatusBar" name="statusBar"/>
    49. </widget>
    50. <layoutdefault spacing="6" margin="11"/>
    51. <resources/>
    52. <connections/>
    53. </ui>
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QCalendarWidget and QGraphicsBlurEffect

    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
    Qt Code:
    1. effect->setBlurHints(QGraphicsBlurEffect::QualityHint);
    To copy to clipboard, switch view to plain text mode 
    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/0...nd-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

  3. #3
    Join Date
    Sep 2009
    Location
    Poland, Cracow
    Posts
    34
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QCalendarWidget and QGraphicsBlurEffect

    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.

Similar Threads

  1. How to use QGraphicsBlurEffect on a widget?
    By ffii4455 in forum Qt Programming
    Replies: 0
    Last Post: 17th February 2012, 13:21
  2. QML and QCalendarWidget
    By estanisgeyer in forum Qt Quick
    Replies: 3
    Last Post: 23rd September 2011, 17:09
  3. QGraphicsBlurEffect on pixmap
    By evergreen in forum Qt Programming
    Replies: 3
    Last Post: 8th June 2011, 11:13
  4. Replies: 0
    Last Post: 15th December 2010, 16:43
  5. Replies: 3
    Last Post: 22nd August 2010, 09:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.