import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Layouts 1.12 import QtQuick.Controls 2.12 ApplicationWindow { visible: true title: qsTr("Преобразователь температур") // Размер окна по размеру содержимого с учетом отступов. width: layout.implicitWidth + layout.anchors.leftMargin + layout.anchors.rightMargin height: layout.implicitHeight + layout.anchors.topMargin + layout.anchors.bottomMargin GridLayout { id: layout anchors.fill: parent anchors.margins: 10 rowSpacing: 10 columns: 3 rows: 2 Label { text: "Градусы Фаренгейта:" } TextField { id: textF // Растягивать по ширине. Layout.fillWidth: true Layout.minimumWidth: 50 inputMethodHints: Qt.ImhFormattedNumbersOnly text: "97,88" focus: true Component.onCompleted: selectAll() } Button { Layout.leftMargin: 5 text: "Преобразовать" onClicked: { var l = Qt.locale(); try { var f = Number.fromLocaleString(l, textF.text); // TODO: вычислить значение c // textC.text = Number(c).toLocaleString(l, 'f', 2); } catch (e) { // TODO: обработать ошибку } } } Label { text: "Градусы Цельсия:" } TextField { id: textC Layout.fillWidth: true text: "36,6" readOnly: true } Item {} } }