How to make a QQuickView window transparent as well as its container widget



  • I have two widgets in a stack, a basic label that has a red background and a QQuicIVew in a widget from QWidgert::createWindowContainer. The qml code has only a small blue rectangle. I would like to be able to see the red label when the container widget is on top. I see the blue rectangle, but what is not blue is "black". I have these widgets on top of one anotehr with a stacklayou, and have trid a a grid laout. Nothing I have tried makes the QQuicView transparent.

    @mainW->setLayout(grid);
    label = new QLabel("HOWDY");
    QPalette pal = label->palette();
    pal.setColor(QPalette::Window,Qt::red);
    pal.setColor(QPalette::WindowText,Qt::white);
    label->setAutoFillBackground(true);
    label->setPalette(pal);
    QFont fnt = label->font();
    fnt.setBold(true);
    fnt.setPointSize(24);
    label->setFont(fnt);
    label->setAlignment(Qt::AlignCenter);
    quickV = new QQuickView(QUrl("qrc:hithere.qml"));
    quickV->setColor(Qt::transparent);

    widget = QWidget::createWindowContainer(quickV,this);
    pal= widget->palette();
    pal.setColor( QPalette::Window, Qt::transparent );
    widget->setPalette( pal );
    widget->setAttribute(Qt::WA_TranslucentBackground);
    widget->setAutoFillBackground(true); // tried false to
    //widget->setBackgroundRole( QPalette::Window );
    grid->addWidget(widget,0,0);
    grid->addWidget(label,0,0);@

    also tried stackLayout:
    @ stack->setStackingMode(QStackedLayout::StackAll);
    stack->insertWidget(0,label);
    stack->insertWidget(1,widget);
    stack->setCurrentIndex(1);@

    QML is real simple:
    import QtQuick 2.0

    Rectangle {
    width: 300
    height: 200
    color:"blue"
    }

    Is this possible, and help to get the top QML window/widget transparnt is greatly apprciated


Log in to reply
 

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