QGraphicsOpacityEffect does not work for widget, which is owned to window with mask
Unsolved
General and Desktop
-
Hello.
In my case, QGraphicsOpacityEffect does not work for widget, if the owner of it has a mask. Here is what i do:
QMainWindow mainWindow; // Main Window QWidget widget(&mainWindow, Qt::Window | Qt::FramelessWindowHint); // I creates QWidget with onwer widget.setAttribute(Qt::WA_NoSystemBackground, true); widget.setAttribute(Qt::WA_TranslucentBackground, true); QWidget background(&widget); background.setStyleSheet("QWidget {background: rgba(255, 50, 80, 1.0)}"); // setup background. QTimer::singleShot(2000, [&]() { auto effect = new QGraphicsOpacityEffect(&widget); widget.setGraphicsEffect(effect); auto animation = new QPropertyAnimation(effect, "opacity"); animation->setDuration(3000); animation->setEndValue(0.01); animation->start(); // Start fade out in 2 sec. }); mainWindow.show(); widget.show();
it works correctly. In 2 seconds widget will start to disappear.
If i add this code after QMainWindow mainWindow:
QMainWindow mainWindow QRegion reg(0, 0, mainWindow.width(), mainWindow.height()); mainWindow.setMask(reg);
QGraphicsOpacityEffect stops work. The widget will not disappear.
Is there a method to fix my problem?