feat(qtquick): chat example to build up on

This commit is contained in:
Orangerot 2024-07-30 10:56:05 +02:00
parent ef2b0ced30
commit 71aee728b7
6 changed files with 93 additions and 9 deletions

View file

@ -3,9 +3,9 @@ project(itat_challange_olympics)
set(CMAKE_CXX_STANDARD 17)
add_executable(itat_challange_olympics main.cpp)
find_package(Qt6 REQUIRED COMPONENTS Core)
set(CMAKE_AUTORCC ON)
qt_add_executable(itat_challange_olympics application.qrc main.cpp)
target_link_libraries(itat_challange_olympics PRIVATE Qt6::Core)
find_package(Qt6 REQUIRED COMPONENTS Quick)

27
EventInfoPage.qml Normal file
View file

@ -0,0 +1,27 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
Page {
id: root
property string event_id
header: ToolBar {
ToolButton {
text: qsTr("Back")
anchors.left: parent.left
anchors.leftMargin: 10
anchors.verticalCenter: parent.verticalCenter
onClicked: root.StackView.view.pop()
}
Label {
id: pageTitle
font.pixelSize: 20
anchors.centerIn: parent
text: qsTr("Event Info")
}
}
}

37
EventsPage.qml Normal file
View file

@ -0,0 +1,37 @@
import QtQuick
import QtQuick.Controls
Page {
id: root
header: ToolBar {
Label {
text: qsTr("Olympia 2024 Events")
font.pixelSize: 20
anchors.centerIn: parent
}
}
ListView {
id: listView
anchors.fill: parent
topMargin: 48
leftMargin: 48
bottomMargin: 48
rightMargin: 48
spacing: 20
model: ["Albert Einstein", "Ernest Hemingway", "Hans Gude"]
delegate: ItemDelegate {
text: modelData
width: listView.width - listView.leftMargin - listView.rightMargin
height: avatar.implicitHeight + 32
leftPadding: avatar.implicitWidth + 32
onClicked: root.StackView.view.push("EventInfoPage.qml", { event_id: 1 })
Image {
id: avatar
// source: "images/" + modelData.replace(" ", "_") + ".png"
}
}
}
}

View file

@ -6,8 +6,10 @@ ApplicationWindow {
height: 400
visible: true
Button {
id: button
text: "A Special Button"
StackView {
id: stackView
anchors.fill: parent
initialItem: EventsPage {}
}
}

6
application.qrc Normal file
View file

@ -0,0 +1,6 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
<file>qtquickcontrols2.conf</file>
</qresource>
</RCC>

12
qtquickcontrols2.conf Normal file
View file

@ -0,0 +1,12 @@
[Controls]
Style=Material
[Universal]
Theme=Material
Accent=Red
[Material]
Theme=Light
Accent=Teal
Primary=BlueGrey