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 overly a transparent QWidget on a QWindow?
Qt 6.11 is out! See what's new in the release blog

How to overly a transparent QWidget on a QWindow?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.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.
  • L Offline
    L Offline
    lygstate
    wrote on last edited by
    #1

    In the following code, scadeWindow is a instance of customized class ScadeWindow which is a subclass of QWindow. Now I want to put a transparent QLabel on scadeWindow, but failed.
    request for a solution for this problem.

    @
    ScadeWidget::ScadeWidget(QWidget *parent):QWidget(parent)
    {
    QSurfaceFormat format;
    format.setSamples(16);
    scadeWindow = new ScadeWindow(format);

    // Combining Qt Widgets and QML with QWidget::createWindowContainer()
    //  http://www.ics.com/blog/combining-qt-widgets-and-qml-qwidgetcreatewindowcontainer#.UlzdRlAge-U
    // OpenGL in Qt 5.1 – Part 5
    //  http://www.kdab.com/opengl-in-qt-5-1-part-5/
    // OpenGL Window Example
    //  http://qt-project.org/doc/qt-5.1/qtgui/openglwindow.html
    container = QWidget::createWindowContainer(scadeWindow, this);
    container->setAttribute(Qt::WA_TranslucentBackground);
    container->setMinimumSize(scadeWindow->width(), scadeWindow->height());
    auto label = new QLabel("Hello, the world!", this);
    label->setAttribute(Qt::WA_TranslucentBackground);
    label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    

    }
    @
    I use this

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NicuPopescu
      wrote on last edited by
      #2

      what if add:

      @label->setStyleSheet("background:transparent");@

      ?

      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