mirror of
https://github.com/Xevion/orianne.git
synced 2025-12-06 05:15:42 -06:00
Initial commit
This commit is contained in:
59
.gitignore
vendored
Normal file
59
.gitignore
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
.vscode/
|
||||
|
||||
# qt
|
||||
.qt/
|
||||
.rcc/
|
||||
calculatorbuilder_autogen/
|
||||
|
||||
### C++ ###
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
### CMake ###
|
||||
CMakeLists.txt.user
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
_deps
|
||||
|
||||
### CMake Patch ###
|
||||
# External projects
|
||||
*-prefix/
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/c++,cmake
|
||||
52
CMakeLists.txt
Normal file
52
CMakeLists.txt
Normal file
@@ -0,0 +1,52 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(calculatorbuilder LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
if(NOT DEFINED INSTALL_EXAMPLESDIR)
|
||||
set(INSTALL_EXAMPLESDIR "examples")
|
||||
endif()
|
||||
|
||||
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/designer/calculatorbuilder")
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui UiTools Widgets)
|
||||
|
||||
qt_add_executable(calculatorbuilder main.cpp)
|
||||
|
||||
set_target_properties(calculatorbuilder PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
MACOSX_BUNDLE TRUE
|
||||
)
|
||||
|
||||
#! [0]
|
||||
target_link_libraries(calculatorbuilder PUBLIC
|
||||
Qt::Core
|
||||
Qt::Gui
|
||||
Qt::UiTools
|
||||
Qt::Widgets
|
||||
)
|
||||
#! [0]
|
||||
|
||||
# Resources:
|
||||
#! [1]x
|
||||
set(calculatorbuilder_resource_files
|
||||
"calculatorform.ui"
|
||||
)
|
||||
#! [1]
|
||||
|
||||
qt6_add_resources(calculatorbuilder "calculatorbuilder"
|
||||
PREFIX
|
||||
"/forms"
|
||||
FILES
|
||||
${calculatorbuilder_resource_files}
|
||||
)
|
||||
|
||||
install(TARGETS calculatorbuilder
|
||||
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
)
|
||||
BIN
calculatorbuilder
Executable file
BIN
calculatorbuilder
Executable file
Binary file not shown.
303
calculatorform.ui
Normal file
303
calculatorform.ui
Normal file
@@ -0,0 +1,303 @@
|
||||
<ui version="4.0" >
|
||||
<author></author>
|
||||
<comment></comment>
|
||||
<exportmacro></exportmacro>
|
||||
<class>CalculatorForm</class>
|
||||
<widget class="QWidget" name="CalculatorForm" >
|
||||
<property name="objectName" >
|
||||
<string notr="true" >CalculatorForm</string>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>276</width>
|
||||
<height>98</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Calculator Builder</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="objectName" >
|
||||
<string notr="true" />
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="objectName" >
|
||||
<string notr="true" />
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="objectName" >
|
||||
<string notr="true" />
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="objectName" >
|
||||
<string notr="true" >label</string>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>1</x>
|
||||
<y>1</y>
|
||||
<width>45</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Input 1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="inputSpinBox1" >
|
||||
<property name="objectName" >
|
||||
<string notr="true" >inputSpinBox1</string>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>1</x>
|
||||
<y>26</y>
|
||||
<width>45</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="mouseTracking" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="objectName" >
|
||||
<string notr="true" >label_3</string>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>54</x>
|
||||
<y>1</y>
|
||||
<width>7</width>
|
||||
<height>52</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>+</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="objectName" >
|
||||
<string notr="true" />
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="objectName" >
|
||||
<string notr="true" >label_2</string>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>1</x>
|
||||
<y>1</y>
|
||||
<width>45</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Input 2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="inputSpinBox2" >
|
||||
<property name="objectName" >
|
||||
<string notr="true" >inputSpinBox2</string>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>1</x>
|
||||
<y>26</y>
|
||||
<width>45</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="mouseTracking" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3_2" >
|
||||
<property name="objectName" >
|
||||
<string notr="true" >label_3_2</string>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>1</y>
|
||||
<width>7</width>
|
||||
<height>52</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>=</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="objectName" >
|
||||
<string notr="true" />
|
||||
</property>
|
||||
<property name="margin" >
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2_2_2" >
|
||||
<property name="objectName" >
|
||||
<string notr="true" >label_2_2_2</string>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>1</x>
|
||||
<y>1</y>
|
||||
<width>37</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Output</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="outputWidget" >
|
||||
<property name="objectName" >
|
||||
<string notr="true" >outputWidget</string>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>1</x>
|
||||
<y>24</y>
|
||||
<width>37</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignAbsolute|Qt::AlignBottom|Qt::AlignCenter|Qt::AlignHCenter|Qt::AlignHorizontal_Mask|Qt::AlignJustify|Qt::AlignLeading|Qt::AlignLeft|Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing|Qt::AlignVCenter|Qt::AlignVertical_Mask</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<spacer>
|
||||
<property name="objectName" >
|
||||
<string notr="true" >verticalSpacer</string>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>85</x>
|
||||
<y>69</y>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<spacer>
|
||||
<property name="objectName" >
|
||||
<string notr="true" >horizontalSpacer</string>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>188</x>
|
||||
<y>26</y>
|
||||
<width>79</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
67
main.cpp
Normal file
67
main.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
//! [0]
|
||||
#include <QtUiTools>
|
||||
//! [0]
|
||||
|
||||
#include <QApplication>
|
||||
#include <QLabel>
|
||||
#include <QSpinBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <QFile>
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
//! [1]
|
||||
static QWidget *loadCalculatorForm(QWidget *parent = nullptr)
|
||||
{
|
||||
QUiLoader loader;
|
||||
|
||||
QFile file(u":/forms/calculatorform.ui"_s);
|
||||
if (!file.open(QFile::ReadOnly))
|
||||
return nullptr;
|
||||
QWidget *formWidget = loader.load(&file, parent);
|
||||
file.close();
|
||||
if (formWidget == nullptr)
|
||||
return nullptr;
|
||||
//! [1]
|
||||
|
||||
//! [2]
|
||||
auto *inputSpinBox1 = formWidget->findChild<QSpinBox*>(u"inputSpinBox1"_s);
|
||||
auto *inputSpinBox2 = formWidget->findChild<QSpinBox*>(u"inputSpinBox2"_s);
|
||||
auto *outputWidget = formWidget->findChild<QLabel*>(u"outputWidget"_s);
|
||||
//! [2]
|
||||
|
||||
//! [3]
|
||||
auto updateResult = [inputSpinBox1, inputSpinBox2, outputWidget]()
|
||||
{
|
||||
const int sum = inputSpinBox1->value() + inputSpinBox2->value();
|
||||
outputWidget->setText(QString::number(sum));
|
||||
};
|
||||
QObject::connect(inputSpinBox1, &QSpinBox::valueChanged, formWidget, updateResult);
|
||||
QObject::connect(inputSpinBox2, &QSpinBox::valueChanged, formWidget, updateResult);
|
||||
//! [3]
|
||||
|
||||
return formWidget;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
QWidget w;
|
||||
auto *formWidget = loadCalculatorForm(&w);
|
||||
if (formWidget == nullptr)
|
||||
return -1;
|
||||
//! [4]
|
||||
auto *layout = new QVBoxLayout(&w);
|
||||
layout->addWidget(formWidget);
|
||||
w.setWindowTitle(QCoreApplication::translate("CalculatorForm",
|
||||
"Calculator Builder"));
|
||||
//! [4]
|
||||
w.show();
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user