summaryrefslogtreecommitdiffstats
path: root/tests/manual/shared/textdialog.cpp
blob: 4e1a5d10ce1e3f021962a55e5a63145d6a6cdd05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#include "textdialog.h"

#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QPlainTextEdit>
#include <QtWidgets/QVBoxLayout>

#include <QtGui/QFontDatabase>

TextDialog::TextDialog(const QString &text, QWidget *parent) : QDialog(parent)
{
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
    auto layout = new QVBoxLayout(this);
    auto pe = new QPlainTextEdit(text, this);
    pe->setReadOnly(true);
    pe->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
    layout->addWidget(pe);

    auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
    layout->addWidget(buttonBox);
    connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
}