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 make a QQuickView window transparent as well as its container widget
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.1k Views 1 Watching
  • 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.
  • D Offline
    D Offline
    DBoosalis
    wrote on last edited by
    #1

    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

    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