Qt6 topics merged with General

QGraphicsOpacityEffect does not work for widget, which is owned to window with mask

  • 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);
    	auto animation = new QPropertyAnimation(effect, "opacity");
    	animation->start();  // Start fade out in 2 sec.

    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());

    QGraphicsOpacityEffect stops work. The widget will not disappear.

    Is there a method to fix my problem?

Log in to reply