Adding TextField view

This commit is contained in:
Selim Mustafaev 2023-06-12 12:22:07 +03:00
parent fd3ce483f0
commit 092f4ea2b5
3 changed files with 49 additions and 4 deletions

View File

@ -5,7 +5,7 @@ project(AutoCatQt VERSION 0.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_PREFIX_PATH "/home/selim/qt/6.4.3/gcc_64/lib/cmake") 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) find_package(nlohmann_json REQUIRED)
qt_standard_project_setup() qt_standard_project_setup()
@ -17,8 +17,7 @@ qt_add_executable(appAutoCatQt
qt_add_qml_module(appAutoCatQt qt_add_qml_module(appAutoCatQt
URI AutoCatQt URI AutoCatQt
VERSION 1.0 VERSION 1.0
QML_FILES views/LoginWindow.qml QML_FILES views/LoginWindow.qml views/MainWindow.qml views/TextField.qml
QML_FILES views/MainWindow.qml
) )
set_target_properties(appAutoCatQt PROPERTIES set_target_properties(appAutoCatQt PROPERTIES

View File

@ -1,9 +1,33 @@
import QtQuick import QtQuick
import QtQuick.Window import QtQuick.Window
import QtQuick.Controls
import QtQuick.Layouts
Window { Window {
height: 480 height: 480
width: 640
title: "Login" title: "Login"
visible: true 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"
}
}
} }

22
views/TextField.qml Normal file
View File

@ -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
}
}