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. How to create a partially transparent overlay widget?
Forum Updated to NodeBB v4.3 + New Features

How to create a partially transparent overlay widget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 194 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.
  • N Offline
    N Offline
    neuclic
    wrote on last edited by
    #1

    I have a stacked layout with two widgets, stacked mode is set to all, widget in blue in the pic is the baselayer, and in pink is the overlay widget(actually it takes up the whole window but my intend is to limit it to the pink area); overlay wiget has two children, one is stretch and the other is a widget; I want to interact with both layers at the same time, so I try to set the stretch of the overlay widget to be transparent and set attribute transparent for mouse event mode, while maintaining the pink widget's state; but I found out I could just either set the entire overlay widget to transparent mode or not; does anybody have ideas? thx a lot
    屏幕截图 2024-04-26 130923.png
    Code snippet:

    QHBoxLayout *secondLayer = new QHBoxLayout(tab1);
        secondLayer->addStretch(1);
        secondLayer->addWidget(friendsListWidget);
        secondWidget = new QWidget();
        secondWidget->setLayout(secondLayer);
        friendsListWidget->setFixedWidth(200);
        secondWidget->setAttribute(Qt::WA_TransparentForMouseEvents);
        friendsListWidget->setAttribute(Qt::WA_TransparentForMouseEvents, false);
        secondWidget->setStyleSheet("background-color: transparent;");
    
    
        QStackedLayout *stackedLayout = new QStackedLayout(tab1);
        stackedLayout->setStackingMode(QStackedLayout::StackAll);
        stackedLayout->addWidget(secondWidget);
        stackedLayout->addWidget(firstlayerWidget);
    
        firstlayerWidget->setVisible(true);
        secondWidget->setVisible(true);
    
    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