QMdiSubWindow with transparency and opacity

  • Hi guys,

    I trying to create new QMdiSubWindow with transparency and opacity to be able to see the background of QMdiArea.

    I try to overwrite paintEvent like this:

    void MdiSubWindow::paintEvent(QPaintEvent *aEvent)
        QPainter painter(this);
        painter.setRenderHint(QPainter::Antialiasing, true);
        painter.drawRoundedRect(0, 0 , width(), height(), 20.0, 20.0);
        // QWidget::paintEvent(aEvent);

    And then a in CSS try this:

    QMdiSubWindow {
        border: 1px solid transparent;
        border-radius: 100px;
        opacity: 0.5;
        background: tranparent;
    QMdiSubWindow QWidget {
        background: transparent;
    QMdiSubWindow:title {
        height: 18px;
        background: transparent;
    QMdiSubWindow #accept {
        background: green;
        border: 1px solid #000000;
        margin: 10px;
        border-radius: 5px;
    QMdiSubWindow #cancel {
        background: red;
        border: 1px solid #000000;
        margin: 10px;
        border-radius: 5px;

    The window look like this:

    Alt text

    But i cant remove the default background of QMdiSubWindow. Can anyone help me?

  • @scastiello You cas use

    in your MdiSubWindow class

  • It works perfectly , thank you very much. :)

  • Lifetime Qt Champion


    @Malek_Khlif said:


    Just beware, that one has nothing to do with painting. Depending on how you handle your mdi sub windows you will have surprises.

  • Yes of course

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.