summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets/stylesheet/mainwindow.cpp
blob: a43613c757dc91f9d4c43081177052ca7bc85d06 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include "mainwindow.h"
#include "stylesheeteditor.h"

#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    ui.setupUi(this);

    ui.nameLabel->setProperty("class", "mandatory QLabel");
    ui.nameCombo->lineEdit()->setPlaceholderText(tr("Last, First"));

    styleSheetEditor = new StyleSheetEditor(this);

    statusBar()->addWidget(new QLabel(tr("Ready")));

    connect(ui.exitAction, &QAction::triggered, qApp, &QApplication::quit);
    connect(ui.aboutQtAction, &QAction::triggered, qApp, &QApplication::aboutQt);
}

void MainWindow::on_editStyleAction_triggered()
{
    styleSheetEditor->show();
    styleSheetEditor->activateWindow();
}

void MainWindow::on_aboutAction_triggered()
{
    const QString url = QStringLiteral("http://doc.qt.io/qt-%1/stylesheet.html")
        .arg(QT_VERSION_MAJOR);
    QMessageBox::about(this, tr("About Style sheet"),
        tr("The <b>Style Sheet</b> example shows how widgets can be styled "
           "using <a href=\"%1\">Qt "
           "Style Sheets</a>. Click <b>File|Edit Style Sheet</b> to pop up the "
           "style editor, and either choose an existing style sheet or design "
           "your own.").arg(url));
}