Important: Please read the Qt Code of Conduct -

How to overlay a floating transparent widget on top another widget?

  • Hi all,

    I ran into a problem with my UI design recently.

    Say my UI would consist of 3 parts, a banner, a display area, and a menu bar. The banner and display area would be put together on the same QStackedWidget page, while the menu bar would be on another page.

    To visualize, it looks something like this:

    First page:

    • Banner

    • Display
    •  Area


    Second page:


    • M
    • E
    • N
    • U

    On the right side of the menu, there's a spacer to keep the menu on the left.

    I imagine I can just call QWidget::raise () on the second page when a menu is needed. However, this will cause the banner widget and display widget un-clickable(Because the first page is now underneath the second page). So I was thinking maybe I can make the second page widget Qt::WA_TransparentForMouseEvents, but this will cause the buttons on the second page to be un-clickable.

    I understand that I might be able to get around this problem with propagating mouseEvent, but at the same time I'm wondering if there is a better solution to my problem?


Log in to reply