Files
qt5-legatus-legacy/Lts/Plugins/PresentationManagement/Gui/Script/ScriptEditor/pre_screen.cpp
T
2026-08-13 18:33:10 +02:00

36 lines
706 B
C++
Executable File

#include "pre_screen.h"
#include <QStyleOption>
#include <QPainter>
Screen::Screen()
: QWidget()
{
setBgColor(QColor("black"));
setContentsMargins(0, 0, 0, 0);
}
Screen::~Screen()
{
const auto p1Widgets = findChildren<QWidget *>(QString(), Qt::FindDirectChildrenOnly);
for (QWidget *w : p1Widgets)
w->setParent(nullptr);
}
void Screen::setBgColor(const QColor &color)
{
setStyleSheet(QStringLiteral("Screen { background: %1; background-color: %1; }").arg(color.name()));
}
void Screen::paintEvent(QPaintEvent *) // needed to apply the style sheet...........
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}