Files
qt-creator/tests/manual/layoutbuilder/v2/main.cpp
hjk 308fb3f3fd LayoutBuilder: Update demo
Backport the learnings and simplification from the real use to
the demo case.

Change-Id: I3f501b03c760484961bfd586735c0db53ba080db
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2024-05-28 05:51:05 +00:00

80 lines
2.0 KiB
C++

// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "lb.h"
#include <QApplication>
#include <QWidget>
#include <QLabel>
#include <QGroupBox>
#include <QTextEdit>
using namespace Layouting;
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
TextEdit::Id textId;
QWidget *w = nullptr;
QGroupBox *g = nullptr;
QLabel *l = nullptr;
Group {
bindTo(&w), // Works, as GroupInterface derives from WidgetInterface
// bindTo(&l), // Does (intentionally) not work, GroupInterface does not derive from LabelInterface
bindTo(&g),
size(300, 200),
title("HHHHHHH"),
Form {
"Hallo",
Group {
title("Title"),
Column {
Label {
text("World")
},
TextEdit {
id(&textId),
text("Och noe")
}
}
},
br,
"Col",
Column {
Row { "1", "2", "3" },
Row { "3", "4", "6" }
},
br,
"Grid",
Grid {
Span { 2, QString("1111111") }, "3", br,
"3", "4", "6", br,
"4", empty, "6", br,
hr, "4", "6"
},
br,
Column {
Label {
text("Hi"),
size(30, 20)
},
Row {
SpinBox {
onTextChanged([&](const QString &text) { textId->setText(text); })
},
st,
PushButton {
text("Quit"),
onClicked(QApplication::quit, nullptr)
}
}
}
}
}.show();
return app.exec();
}