Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGraphicsOpacityEffect does not work for widget, which is owned to window with mask

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 700 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • UnickU Offline
    UnickU Offline
    Unick
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved