From 092f4ea2b56bf896a4beee46ed3aae47b89b7b81 Mon Sep 17 00:00:00 2001 From: Selim Mustafaev Date: Mon, 12 Jun 2023 12:22:07 +0300 Subject: [PATCH] Adding TextField view --- CMakeLists.txt | 5 ++--- views/LoginWindow.qml | 26 +++++++++++++++++++++++++- views/TextField.qml | 22 ++++++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 views/TextField.qml diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fa4f64..bfe5ad3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ project(AutoCatQt VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_PREFIX_PATH "/home/selim/qt/6.4.3/gcc_64/lib/cmake") -find_package(Qt6 6.4 REQUIRED COMPONENTS Quick) +find_package(Qt6 6.4 REQUIRED COMPONENTS Quick QuickControls2) find_package(nlohmann_json REQUIRED) qt_standard_project_setup() @@ -17,8 +17,7 @@ qt_add_executable(appAutoCatQt qt_add_qml_module(appAutoCatQt URI AutoCatQt VERSION 1.0 - QML_FILES views/LoginWindow.qml - QML_FILES views/MainWindow.qml + QML_FILES views/LoginWindow.qml views/MainWindow.qml views/TextField.qml ) set_target_properties(appAutoCatQt PROPERTIES diff --git a/views/LoginWindow.qml b/views/LoginWindow.qml index 2c8ba2c..a7ed59a 100644 --- a/views/LoginWindow.qml +++ b/views/LoginWindow.qml @@ -1,9 +1,33 @@ import QtQuick import QtQuick.Window +import QtQuick.Controls +import QtQuick.Layouts Window { height: 480 - width: 640 title: "Login" visible: true + width: 640 + + ColumnLayout { + anchors.centerIn: parent + spacing: 16 + width: parent.width * 0.6 + + // TextField { + // id: login + // anchors.left: parent.left + // anchors.right: parent.right + // } + // TextField { + // id: password + // anchors.left: parent.left + // anchors.right: parent.right + // } + + Button { + Layout.fillWidth: true + text: "Log In" + } + } } \ No newline at end of file diff --git a/views/TextField.qml b/views/TextField.qml new file mode 100644 index 0000000..94c483e --- /dev/null +++ b/views/TextField.qml @@ -0,0 +1,22 @@ +import QtQuick +import QtQuick + +FocusScope { + property alias input: input + property alias text: input.text + + height: input.contentHeight + 8 + + Rectangle { + anchors.fill: parent + border.color: "gray" + color: "lightsteelblue" + } + TextInput { + id: input + + anchors.fill: parent + anchors.margins: 4 + focus: true + } +}