Post 2/2
ContentsPage.qml
import QtQuick 2.0
Item {
id: mainContents
Text {
id: keywordText
color: "#ffffff"
anchors.verticalCenter: keywordComboBox.verticalCenter
anchors.right: authorsIndexText.right
wrapMode: Text.WordWrap
text: "<b>Keyword</b>"
font.pixelSize: 16
font.family: "Arial"
}
ComboBox {
id: keywordComboBox
width: 300
height: 20
listBoxHeight: 570
itemColor: "#1a4381"
borderColor: "#ffffff"
anchors.top: indexRect.bottom
anchors.topMargin: 10
anchors.left: indexRect.left
text: "Choose a keyword -->"
imageSource: "images/DownArrow.png"
model: keywordModel
field: KljucnaRijec //this is the name of the column
z: 1
}
}
The line “field: KljucnaRijec” is the one that causes the error
ReferenceError: KljucnaRijec is not defined
main.qml
import QtQuick 2.0
Item {
id: mainItem
width: 1024
FontLoader {
id: avantGardeBookBT
source: "qrc:/fonts/fonts/AvantGardeBookBT.ttf"
}
Rectangle {
id: headerRectangle
//width: parent.width
width: 1024
height: 80
color: "#1a4381"
anchors.horizontalCenter: parent.horizontalCenter
ImageTextButton {
id: exitButton
imageSource: "images/X.png"
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: 5
onImageTextButtonClick: exitDialog.visible = true;
text: "EXIT"
}
}
Rectangle {
id: mainRectangle
//width: parent.width
width: 1024
height: mainItem.height - headerRectangle.height - 1
color: "#1a4381"
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
Component.onCompleted: pageLoader.setSource("HomePage.qml")
signal loadPage(string pageName)
YesNoDialog {
id: exitDialog
anchors.centerIn: parent
visible: false
z: 1
titleText: "Question"
messageText: "Are you sure you want to quit?"
iconSource: "images/Warning.png"
xButtonImageSource: "images/X.png"
onYesClick: Qt.quit();
onNoClick: exitDialog.visible = false;
onExitClick: exitDialog.visible = false;
}
Image {
id: mainBgImage
source: "images/Background1.png"
anchors.fill: parent
}
Loader {
id: pageLoader
anchors.fill: parent
//source: "HomePage.qml"
}
Connections {
id: pageConnections
ignoreUnknownSignals: true
target: pageLoader.item
onLoadPage: {
if (pageName == "ContentsPage.qml")
keywordModel.setModel("KljucneRijeci"); //this will set data from the table specified in quotes to the model
pageLoader.source = pageName;
}
}
}
}
I hope this is clear enough.
Cheers,
Lucijan
P.S. I have a side question: if I try to use this application on Linux or Mac, will I need to install a database driver for MS Access databases or will the program call one of Qt’s library files? I need to make the program work without any installation. If not, will it work if I convert the database to SQLite or some other database?
↧