im using QQmlApplicationEngine with QQuickWindow for an application and i can\'t transparent main window. i want to set a splash before application pops up and i use Window
You might consider using the following code for achieving a frameless transparent window effect:
setWindowFlags(
#ifdef Q_OS_MAC
Qt::SubWindow |
#else
Qt::Tool |
#endif
Qt::FramelessWindowHint |
Qt::WindowSystemMenuHint |
Qt::WindowStaysOnTopHint
);
setAttribute(Qt::WA_NoSystemBackground, true);
// set the parent widget's background to translucent
setAttribute(Qt::WA_TranslucentBackground, true);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
// create a display widget for displaying child widgets
QWidget* displayWidget = new QWidget;
displayWidget->setStyleSheet(".QWidget { background-color: rgba(0, 0, 0, 75%); border-width: 1px; border-style: solid; border-radius: 10px; border-color: #555555; } .QWidget:hover { background-color: rgba(68, 68, 68, 75%); border-width: 2px; border-style: solid; border-radius: 10px; border-color: #ffffff; }");
The idea is that your parent window or containing window has no frame and has a translucent background. Then you nest a child QWidget inside the parent QWidget and apply styles using QSS for transparency.