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. Issue with Frameless Window and createWindowContainer Causing UI Not to Refresh on Qt 5.15 (Windows)
Forum Updated to NodeBB v4.3 + New Features

Issue with Frameless Window and createWindowContainer Causing UI Not to Refresh on Qt 5.15 (Windows)

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

    I am encountering a problem using Qt 5.15 on the Windows platform. I have created a minimum reproducible example to demonstrate the issue.

    The issue arises when I use Qt::FramelessWindowHint and Qt::WA_TranslucentBackground for a frameless window, and then wrap this window with QWidget::createWindowContainer. After doing so, the UI of the frameless window becomes unresponsive and does not refresh properly.|

    Here is the code snippet:

    #include <QApplication>
    #include <QWidget>
    #include <QLabel>
    #include <QVBoxLayout>
    #include <QPalette>
    #include <QWindow>
    #include <QPushButton>
    #include <QDateTime>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        QWidget* mainWindow = new QWidget();
        mainWindow->setWindowTitle("Main Window");
        mainWindow->resize(300, 400);
    
        QPalette pal1;
        pal1.setColor(QPalette::Window, QColor(200, 230, 255));  // Light blue
        mainWindow->setAutoFillBackground(true);
        mainWindow->setPalette(pal1);
    
        QVBoxLayout* layout1 = new QVBoxLayout(mainWindow);
    
        QLabel* label1 = new QLabel("Hello, yaminet1024!");
        label1->setAlignment(Qt::AlignCenter);
        layout1->addWidget(label1);
    
        QWidget* framelessWindow = new QWidget();
        framelessWindow->setWindowFlags(Qt::FramelessWindowHint);
        framelessWindow->setAttribute(Qt::WA_TranslucentBackground);
        framelessWindow->resize(200, 150);
    
        QVBoxLayout* layout2 = new QVBoxLayout(framelessWindow);
        QLabel* label2 = new QLabel("2025-04-17 17:23:07");
        label2->setAlignment(Qt::AlignCenter);
        layout2->addWidget(label2);
    
        // Add refresh button
        QPushButton* refreshBtn = new QPushButton("Refresh");
        refreshBtn->setFixedSize(80, 30);
        refreshBtn->setStyleSheet(
            "QPushButton { background: #FFB6C1; border: 1px solid #FF69B4; border-radius: 5px; }"
            "QPushButton:hover { background: #FFC0CB; }"
            "QPushButton:pressed { background: #FF1493; }"
        );
    
        // Connect button click to update text
        QObject::connect(refreshBtn, &QPushButton::clicked, [label2](){
            QDateTime currentTime = QDateTime::currentDateTime();
            label2->setText(currentTime.toString("yyyy-MM-dd hh:mm:ss"));
        });
    
        layout2->addWidget(refreshBtn, 0, Qt::AlignHCenter);
    
        framelessWindow->show();
    
        QWindow* window = QWindow::fromWinId(framelessWindow->winId());
    
        QWidget* container = QWidget::createWindowContainer(window, mainWindow);
        container->setMinimumSize(200, 150);
        layout1->addWidget(container);
    
        mainWindow->show();
    
        return a.exec();
    }
    

    In this example:

    The framelessWindow is set with the Qt::FramelessWindowHint and Qt::WA_TranslucentBackground flags.
    The frameless window is then wrapped with QWidget::createWindowContainer.
    The Refresh button is supposed to update the timestamp shown in the framelessWindow. However, after wrapping the frameless window in createWindowContainer, the UI becomes unresponsive and fails to refresh properly.

    I suspect this might be a limitation or a bug related to the use of createWindowContainer with frameless windows using these specific flags.

    Has anyone encountered a similar issue or knows of a workaround? Any help is greatly appreciated!

    Thank you!

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      I tested it with a recent Qt6 version and could not see any pushbutton at all.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      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