Ich versuche mich mal in ein Größeres Projekt. Bein drücken des Save-Button sollen die Daten in das TableView übernommen werden.
Mein Problem ist nun das die Daten von der ComboBox nicht übernommen werden.
Ich hänge mal das komplette Programm an.
Grüße und gute Gedanken Dirk
Code: Alles auswählen
import QtQuick 2.4
import Ubuntu.Components 1.3
import QtQuick.Controls 1.4
import QtQuick.Window 2.2
import QtQuick.Controls.Styles 1.4
import QtQuick 2.4
/*
SOTA Logbuch (c) DL8AAX
*/
MainView {
id: mainView
// objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView"
// Note! applicationName needs to match the "name" field of the click manifest
applicationName: "8aaxsotalog.dl8aax"
width: units.gu(50)
height: units.gu(75)
property string comboausw: ""
Rectangle {
id: rectangle1
x: 0
y: 0
width: 400
height: 92
color: "#ffffff"
/////////////////////////////////////////////////////// Eingabefelder /////////////////////////////////////////////////////////
Rectangle {
id: rectangle1a
x: 1
y: 1
width: 69
height: 20
color: "#fecece"
radius: 2
z: 1
border.color: "#f40606"
border.width: 2
TextInput {
id: textInput1
width: 72
height: 15
color: "#1b0000"
text: "12.12.2017"
selectionColor: "#00801c"
z: 2
font.family: "Arial"
//p text: qsTr("")
font.pointSize: FontUtils.sizeToPixels("x-small")
}
}
Text {
id: text1
x: 0
y: 21
width: 47
height: 13
text: qsTr("Datum")
styleColor: "#f33535"
anchors.left: rectangle1a.left
anchors.leftMargin: 2
anchors.top: rectangle1a.bottom
anchors.topMargin: 4
font.pointSize: FontUtils.sizeToPixels("x-small")
}
//
Rectangle {
id: rectangle2
x: 76
y: 1
width: 40
height: 20
color: "#fecece"
radius: 2
border.color: "#f40606"
border.width: 2
TextInput {
id: textInput2
y: 2
width: 40
height: 15
color: "#1b0000"
text: "12:12"
anchors.left: parent.left
anchors.leftMargin: 0
font.family: "Arial"
//p text: qsTr("")
font.pointSize: FontUtils.sizeToPixels("x-small")
}
}
Text {
id: text2
x: 76
y: 21
width: 40
height: 13
text: qsTr("UTC")
styleColor: "#f33535"
anchors.left: rectangle2.left
anchors.leftMargin: 2
anchors.top: rectangle2.bottom
anchors.topMargin: 4
font.pointSize: FontUtils.sizeToPixels("x-small")
}
//
Rectangle {
id: rectangle3
x: 122
y: 1
width: 52
height: 20
color: "#fecece"
radius: 2
border.color: "#f40606"
border.width: 2
TextInput {
id: textInput3
y: 2
width: 52
height: 15
z: 2
color: "#1b0000"
text: "dl7rtz/p"
anchors.left: parent.left
anchors.leftMargin: 0
font.family: "Arial"
//p text: qsTr("")
font.pointSize: FontUtils.sizeToPixels("x-small")
}
}
Text {
id: text3
x: 122
y: 21
width: 47
height: 13
text: qsTr("Call")
styleColor: "#f33535"
anchors.left: rectangle3.left
anchors.leftMargin: 2
anchors.top: rectangle3.bottom
anchors.topMargin: 4
font.pointSize: FontUtils.sizeToPixels("x-small")
}
//
Rectangle {
id: rectangle4
x: 180
y: 1
z: 1
width: 80
height: 20
color: "#fecece"
radius: 2
border.color: "#f40606"
border.width: 2
TextInput {
id: textInput4
y: 2
width: 80
height: 15
z: 3
color: "#1b0000"
text: ""
anchors.left: parent.left
anchors.leftMargin: 0
font.family: "Arial"
//p text: qsTr("")
font.pointSize: FontUtils.sizeToPixels("x-small")
}
}
Text {
id: text4
x: 180
y: 21
width: 47
height: 13
text: qsTr("Name")
styleColor: "#f33535"
anchors.left: rectangle4.left
anchors.leftMargin: 2
anchors.top: rectangle4.bottom
anchors.topMargin: 4
font.pointSize: FontUtils.sizeToPixels("x-small")
}
//
Rectangle {
id: rectangle5
x: 266
y: 1
z: 1
width: 80
height: 20
color: "#fecece"
radius: 2
border.color: "#f40606"
border.width: 2
TextInput {
id: textInput5
y: 2
width: rectangle5.width
height: 15
z: 3
color: "#1b0000"
text: ""
anchors.left: parent.left
anchors.leftMargin: 0
font.family: "Arial"
//p text: qsTr("")
font.pointSize: FontUtils.sizeToPixels("x-small")
}
}
Text {
id: text5
x: 266
y: 21
width: 47
height: 13
text: qsTr("QTH")
styleColor: "#f33535"
anchors.left: rectangle5.left
anchors.leftMargin: 2
anchors.top: rectangle5.bottom
anchors.topMargin: 4
font.pointSize: FontUtils.sizeToPixels("x-small")
}
//
Rectangle {
id: rectangle6
x: 1
y: 40
z: 1
width: 47
height: 20
color: "#fecece"
radius: 2
border.color: "#f40606"
border.width: 2
TextInput {
id: textInput6
y: 2
width: rectangle6.width
height: 15
z: 3
color: "#1b0000"
text: ""
anchors.left: parent.left
anchors.leftMargin: 0
font.family: "Arial"
//p text: qsTr("")
font.pointSize: FontUtils.sizeToPixels("x-small")
}
}
Text {
id: text6
x: 1
y: 60
width: 47
height: 13
text: qsTr("RST out")
styleColor: "#f33535"
anchors.left: rectangle6.left
anchors.leftMargin: 2
anchors.top: rectangle6.bottom
anchors.topMargin: 4
font.pointSize: FontUtils.sizeToPixels("x-small")
}
//
Rectangle {
id: rectangle7
x: 56
y: 40
z: 1
width: 47
height: 20
color: "#fecece"
radius: 2
border.color: "#f40606"
border.width: 2
TextInput {
id: textInput7
y: 2
width: rectangle7.width
height: 15
z: 3
color: "#1b0000"
text: ""
anchors.left: parent.left
anchors.leftMargin: 0
font.family: "Arial"
//p text: qsTr("")
font.pointSize: FontUtils.sizeToPixels("x-small")
}
}
Text {
id: text7
x: 56
y: 60
width: 47
height: 13
text: qsTr("RST in")
styleColor: "#f33535"
anchors.left: rectangle7.left
anchors.leftMargin: 2
anchors.top: rectangle7.bottom
anchors.topMargin: 4
font.pointSize: FontUtils.sizeToPixels("x-small")
}
//
Rectangle {
id: rectangle8
x: 109
y: 40
z: 1
width: 47
height: 20
color: "#fecece"
radius: 2
border.color: "#f40606"
border.width: 2
TextInput {
id: textInput8
y: 2
width: rectangle8.width
height: 15
z: 3
color: "#1b0000"
text: ""
anchors.left: parent.left
anchors.leftMargin: 0
font.family: "Arial"
//p text: qsTr("")
font.pointSize: FontUtils.sizeToPixels("x-small")
}
}
Text {
id: text8
x: 109
y: 60
width: 47
height: 13
text: qsTr("QRG")
styleColor: "#f33535"
anchors.left: rectangle8.left
anchors.leftMargin: 2
anchors.top: rectangle8.bottom
anchors.topMargin: 4
font.pointSize: FontUtils.sizeToPixels("x-small")
}
//
Rectangle {
id: rectangle9
x: 170
y: 40
z: 1
width: 80
height: 20
color: "#fecece"
radius: 2
border.color: "#f40606"
border.width: 2
ComboBox {
// y: 43
width: rectangle9.width-6
// anchors.verticalCenter: rectangle9.verticalCenter
anchors.leftMargin: 3
height: 16
anchors.top: parent.top
anchors.topMargin: 2
anchors.left: parent.left
currentIndex: 0
model: ListModel {
id: cbItems
ListElement { text: " "; adr: " " }
ListElement { text: "Data"; adr: "Data" }
ListElement { text: "CW"; adr: "CW" }
ListElement { text: "RTTY"; adr: "RTTY" }
ListElement { text: "AM"; adr: "AM" }
ListElement { text: "FM"; adr: "FM" }
ListElement { text: "SSB"; adr: "SSB" }
ListElement { text: "DSTAR"; adr: "DSTAR"}
}
onCurrentIndexChanged:{
comboausw = cbItems.get(currentIndex.text).text
console.log(comboausw );
//comboausw ="test"
console.log( cbItems.get(currentIndex.text).text)
}
}//ComboBox
}
Text {
id: text9
x: 170
y: 60
width: 47
height: 13
text: qsTr("Mode")
styleColor: "#f33535"
anchors.left: rectangle9.left
anchors.leftMargin: 2
anchors.top: rectangle9.bottom
anchors.topMargin: 4
font.pointSize: FontUtils.sizeToPixels("x-small")
}
//
Rectangle {
id: rectangle10
x: 266
y: 40
z: 1
width: 80
height: 20
color: "#fecece"
radius: 2
border.color: "#f40606"
border.width: 2
TextInput {
id: textInput10
y: 2
width: rectangle10.width
height: 15
z: 3
color: "#1b0000"
text: ""
anchors.left: parent.left
anchors.leftMargin: 0
font.family: "Arial"
//p text: qsTr("")
font.pointSize: FontUtils.sizeToPixels("x-small")
}
}
Text {
id: text10
x: 266
y: 60
width: 47
height: 13
text: qsTr("myQTH")
styleColor: "#f33535"
anchors.left: rectangle10.left
anchors.leftMargin: 2
anchors.top: rectangle10.bottom
anchors.topMargin: 4
font.pointSize: FontUtils.sizeToPixels("x-small")
}
//
Button {
id: button1
y: 60
width: 44
height: 27
text: "Save"
objectName: "button"
anchors {
horizontalCenter: parent.horizontalCenter
}
anchors.horizontalCenterOffset: 174
anchors.topMargin: 33
onClicked: {
//label.text = i18n.tr("..world!")
libraryModel.append({"zid":4,
"datum":textInput1.text,
"zeit":textInput2.text,
"call":textInput3.text,
"name":textInput4.text,
"qrg":textInput8.text,
"mode":comboausw,
"qth":textInput5.text,
"rsts":textInput6.text,
"rstr":textInput7.text,
"myqth":textInput10.text
// "":textInput3.text,
})
}
}//button1
////////////////////////////////////////////////////////////////////////////////////////////////////
}//rect
ListModel {
id: libraryModel
ListElement{ uid: "001" ;datum:"01.02.2017" ;zeit:"12:12"; call: "db4aak/p"; name: "Gabriel" ;qrg:"1250.123";mode:"ssb";qth:"landelfshausen";rsts:"599";rstr:"234" }
ListElement{ uid: "002" ;datum:"30.03.2017" ;zeit:"12:12"; call: "dl9aal/p"; name: "otto" ;qrg:"1250.123";mode:"ssb";qth:"landelfshausen";rsts:"599";rstr:"234" }
}
TableView {
id:tbview
x: 8
y: 98
width: 384
height: 388
sortIndicatorVisible: false
highlightOnFocus: true
TableViewColumn { role: " "; title: " "; width: 10 }
TableViewColumn { role: "uid"; title: "id"; width: 20 }
TableViewColumn { role: "datum"; title: "Date"; width: 80 }
TableViewColumn { role: "zeit"; title: "UTC"; width: 50 }
TableViewColumn { role: "call"; title: "Call"; width: 70 }
TableViewColumn { role: "name"; title: "Name"; width: 100}
TableViewColumn { role: "qrg"; title: "QRG"; width: 70 }
TableViewColumn { role: "mode"; title: "Mode"; width: 50 }
TableViewColumn { role: "qth"; title: "QTH"; width: 120 }
TableViewColumn { role: "rsts"; title: "RSTs"; width: 50 }
TableViewColumn { role: "rstr"; title: "RSTr"; width: 50 }
TableViewColumn { role: "myqth"; title: "myQTH"; width: 120 }
model: libraryModel
// signal clicked(int row)
onClicked: {
console.log("Klick auf Zeile " + tbview.currentRow )
}
}
Button {
id: button2
x: 8
y: 492
width: 42
height: 31
text: qsTr("Edit")
onClicked: {
//label.text = i18n.tr("..world!")
console.log(libraryModel.get(1).call+" "+libraryModel.get(1).name);
console.log(tbview.currentRow );
console.log(tbview.rowCount );
}
}
Button {
id: button3
x: 56
y: 492
width: 53
height: 31
text: qsTr("Delete")
onClicked: {
}
}
//}
//page
}