Hi there and happy easter,

I've the follwing issues:

I made a prog, where there are some labels with drop shadow effect, wich is calculatet relative to the mouse cursor position. (As is the cursor is a light source, it's like in the "Populous 3" menu.

So far it's working, BUT:

Even though I've activated the mousetracking property on every element, when I hover over one of the labels, the effect stops to work, it does only work outside the labels.

And another strange issue is:
Sometimes the hole gui freezes and the output says:

Qt Code:
  1. QPainter::begin: Paint device returned engine == 0, type: 3
  2. QPainter::scale: Painter not active
  3. QPainter::setRenderHint: Painter must be active to set rendering hints
  4. QPainter::end: Painter not active, aborted
To copy to clipboard, switch view to plain text mode 

Then for some short time, it's working again, but next, the shadow completely disappears, and the GUI freezes totally.
And the really strange thing is, that this issue is not there when I run the prog with the debugger! oO

I'm really stuck on this and haven't any clue where the bug might be.

I'm using Qt 5.8.0 64bit on openSUSE 42.1

This is the code:

mainwindow.h:

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

main.cpp:
Qt Code:
  1. #include "mainwindow.h"
  2. #include <QApplication>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QApplication a(argc, argv);
  7. MainWindow w;
  8. w.show();
  9.  
  10. return a.exec();
  11. }
To copy to clipboard, switch view to plain text mode 

mainwindow.cpp:
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <QGraphicsDropShadowEffect>
  4. #include <QDebug>
  5. #include <QMouseEvent>
  6.  
  7.  
  8. MainWindow::MainWindow(QWidget *parent) :
  9. QMainWindow(parent),
  10. ui(new Ui::MainWindow)
  11. {
  12. ui->setupUi(this);
  13. this->setMouseTracking(true);
  14. ui->label->setMouseTracking(true);
  15. ui->label_2->setMouseTracking(true);
  16. ui->label_3->setMouseTracking(true);
  17. ui->label_4->setMouseTracking(true);
  18. ui->widget->setMouseTracking(true);
  19. ui->centralWidget->setMouseTracking(true);
  20. }
  21.  
  22. MainWindow::~MainWindow()
  23. {
  24. delete ui;
  25. }
  26.  
  27. void MainWindow::mouseMoveEvent(QMouseEvent *event){
  28. this->repaint();
  29. QGraphicsDropShadowEffect * dse = new QGraphicsDropShadowEffect();
  30. dse->setBlurRadius(8);
  31. dse->setColor(QColor(0,0,0,180));
  32.  
  33. QGraphicsDropShadowEffect * dse2 = new QGraphicsDropShadowEffect();
  34. dse2->setBlurRadius(8);
  35. dse2->setColor(QColor(0,0,0,180));
  36.  
  37. QGraphicsDropShadowEffect * dse3 = new QGraphicsDropShadowEffect();
  38. dse3->setBlurRadius(8);
  39. dse3->setColor(QColor(0,0,0,180));
  40.  
  41. QGraphicsDropShadowEffect * dse4 = new QGraphicsDropShadowEffect();
  42. dse4->setBlurRadius(8);
  43. dse4->setColor(QColor(0,0,0,180));
  44.  
  45. int centralX = ui->centralWidget->width()/2;
  46. int centralY = ui->centralWidget->height()/2;
  47. int off1x;
  48. int off1y;
  49.  
  50.  
  51. if (event->pos().x() > centralX) {
  52. off1x = centralX - event->pos().x();
  53. //qDebug() << off1x;
  54. }
  55. else if (event->pos().x() < centralX) {
  56. off1x = (event->pos().x() - centralX)*-1;
  57.  
  58. }
  59.  
  60. if (event->pos().y() > centralY) {
  61. off1y = centralY - event->pos().y();
  62.  
  63. }
  64. else if (event->pos().y() < centralY) {
  65. off1y = (event->pos().y() - centralY)*-1;
  66.  
  67. }
  68.  
  69. dse->setOffset((off1x+(ui->label->x()/4))/20,(off1y+(ui->label->y()/4))/20);
  70. dse2->setOffset((off1x+(ui->label_2->x()/4))/20,(off1y+(ui->label_2->y()/4))/20);
  71. dse3->setOffset((off1x+(ui->label_3->x()/4))/20,(off1y+(ui->label_3->y()/4))/20);
  72. dse4->setOffset((off1x+(ui->label_3->x()/4))/20,(off1y+(ui->label_4->y()/4))/20);
  73. ui->label->setGraphicsEffect(dse);
  74. ui->label_2->setGraphicsEffect(dse2);
  75. ui->label_3->setGraphicsEffect(dse3);
  76. ui->label_4->setGraphicsEffect(dse4);
  77.  
  78. }
To copy to clipboard, switch view to plain text mode 

I would appreciate any help!