windowflags: Make it easier to debug windows without a frame

Without any content it was hard to see the window. Put some lipstick on it.

Change-Id: I0fefffb0a4deba7ac91e67a6153a9a27308fe493
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Tor Arne Vestbø 2018-02-16 18:02:45 +01:00
parent 8702e28628
commit 8ef9a0ae89
3 changed files with 18 additions and 1 deletions

View File

@ -59,7 +59,7 @@ ControllerWidget::ControllerWidget(QWidget *parent)
QLabel *label = new QLabel(tr("Parent window"));
parentWindow->setCentralWidget(label);
previewWindow = new QWindow;
previewWindow = new PreviewWindow;
previewWindow->installEventFilter(this);
previewWidget = new PreviewWidget;
previewWidget->installEventFilter(this);

View File

@ -32,9 +32,20 @@
#include <QVBoxLayout>
#include <QTextStream>
#include <QTimer>
#include <QPainter>
#include <QLinearGradient>
#include "previewwindow.h"
void PreviewWindow::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
QLinearGradient gradient(0, 0, width(), height());
gradient.setColorAt(0, QColor("#64b3f4"));
gradient.setColorAt(1, QColor("#c2e59c"));
painter.fillRect(QRect(0, 0, width(), height()), gradient);
}
static void formatWindowFlags(QTextStream &str, Qt::WindowFlags flags)
{
str << "Window flags: " << hex << showbase << unsigned(flags) << noshowbase << dec << ' ';

View File

@ -30,11 +30,17 @@
#define PREVIEWWINDOW_H
#include <QDialog>
#include <QRasterWindow>
QT_BEGIN_NAMESPACE
class QPlainTextEdit;
QT_END_NAMESPACE
class PreviewWindow : public QRasterWindow
{
void paintEvent(QPaintEvent *event);
};
class PreviewWidget : public QWidget
{
Q_OBJECT