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 overlay a QWidget such as QLabel overy a Qt 5.0 QWindow with the transparent part works like QWidget overly QWidget?
Qt 6.11 is out! See what's new in the release blog

How to overlay a QWidget such as QLabel overy a Qt 5.0 QWindow with the transparent part works like QWidget overly QWidget?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.0k 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

    When I use a QLabel overly a QWindow by
    @
    #include "paintedwindow.h"
    #include "ScadeWidget.h"

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <QLabel>

    ScadeWidget::ScadeWidget(QWidget *parent):QWidget(parent)
    {
    scadeWindow = new PaintedWindow;

    // 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->setMinimumSize(scadeWindow->width(), scadeWindow->height());
    

    #if 1
    //We can directly use Qt UI file to overlap OpenGL.
    auto label = new QLabel("Hello, the world!", this);
    label->move(100,50);
    label->setAttribute(Qt::WA_TranslucentBackground);
    label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    #endif
    }
    @
    The showed label comes with non-transparent staff. Ineed, the paintedwindow comes from the qt
    examples C:\Qt\Qt5.1.1\5.1.1\msvc2010_opengl\examples\opengl\paintedwindow

    as the following picture shows, the hello world's background should be blue :
    !http://s15.postimg.org/acxqqtc55/QQ_20131209162947.jpg(The in transparent draw.)!

    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