mirror of
https://github.com/Xevion/orianne.git
synced 2025-12-06 01:15:34 -06:00
Reformat main.cpp
This commit is contained in:
38
main.cpp
38
main.cpp
@@ -1,42 +1,34 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
||||||
|
|
||||||
//! [0]
|
|
||||||
#include <QtUiTools>
|
#include <QtUiTools>
|
||||||
//! [0]
|
#include <QCoreApplication>
|
||||||
|
#include <QtWidgets/QApplication>
|
||||||
#include <QApplication>
|
#include <QtWidgets/QLabel>
|
||||||
#include <QLabel>
|
#include <QtWidgets/QSpinBox>
|
||||||
#include <QSpinBox>
|
#include <QtWidgets/QVBoxLayout>
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using namespace Qt::StringLiterals;
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
//! [1]
|
|
||||||
static QWidget *loadCalculatorForm(QWidget *parent = nullptr)
|
static QWidget *loadCalculatorForm(QWidget *parent = nullptr)
|
||||||
{
|
{
|
||||||
QUiLoader loader;
|
|
||||||
|
|
||||||
QFile file(u":/forms/calculatorform.ui"_s);
|
QFile file(u":/forms/calculatorform.ui"_s);
|
||||||
if (!file.open(QFile::ReadOnly))
|
if (!file.open(QFile::ReadOnly))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
QUiLoader loader;
|
||||||
QWidget *formWidget = loader.load(&file, parent);
|
QWidget *formWidget = loader.load(&file, parent);
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
if (formWidget == nullptr)
|
if (formWidget == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
//! [1]
|
|
||||||
|
|
||||||
//! [2]
|
//! [2]
|
||||||
auto *inputSpinBox1 = formWidget->findChild<QSpinBox*>(u"inputSpinBox1"_s);
|
auto *inputSpinBox1 = formWidget->findChild<QSpinBox *>(u"inputSpinBox1"_s);
|
||||||
auto *inputSpinBox2 = formWidget->findChild<QSpinBox*>(u"inputSpinBox2"_s);
|
auto *inputSpinBox2 = formWidget->findChild<QSpinBox *>(u"inputSpinBox2"_s);
|
||||||
auto *outputWidget = formWidget->findChild<QLabel*>(u"outputWidget"_s);
|
auto *outputWidget = formWidget->findChild<QLabel *>(u"outputWidget"_s);
|
||||||
//! [2]
|
//! [2]
|
||||||
|
|
||||||
//! [3]
|
//! [3]
|
||||||
auto updateResult = [inputSpinBox1, inputSpinBox2, outputWidget]()
|
auto updateResult = [inputSpinBox1, inputSpinBox2, outputWidget]()
|
||||||
{
|
{
|
||||||
const int sum = inputSpinBox1->value() + inputSpinBox2->value();
|
const int sum = inputSpinBox1->value() + inputSpinBox2->value();
|
||||||
@@ -44,7 +36,7 @@ static QWidget *loadCalculatorForm(QWidget *parent = nullptr)
|
|||||||
};
|
};
|
||||||
QObject::connect(inputSpinBox1, &QSpinBox::valueChanged, formWidget, updateResult);
|
QObject::connect(inputSpinBox1, &QSpinBox::valueChanged, formWidget, updateResult);
|
||||||
QObject::connect(inputSpinBox2, &QSpinBox::valueChanged, formWidget, updateResult);
|
QObject::connect(inputSpinBox2, &QSpinBox::valueChanged, formWidget, updateResult);
|
||||||
//! [3]
|
//! [3]
|
||||||
|
|
||||||
return formWidget;
|
return formWidget;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user