Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

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

    General and Desktop
    1
    1
    980
    Loading More Posts
    • 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
      DBoosalis last edited by

      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 Reply Quote 0
      • First post
        Last post