Hi and thanks for your time and attention,
view->engine()->clearComponentCache();
view->engine()->clearComponentCache();
To copy to clipboard, switch view to plain text mode
is an interesting idea! I had not tried that before, but unfortunately it doesn't help, too (same crash).
As to the basic structure of what I am doing here: I have different kinds of incidents in my model which all derive from an "Incident" base class. For interaction with qml I cache this in different interfaces which also derive from one "IncEditInterface", which covers the "Incident" base stuff.
On qml side I use a IncEdit.qml which allows the editing of the base class properties of the interface (most of them invisible by default, opening on demand). The additional properties of the derived classes are covered by a Loader that - depending on the actual class - sideloads additional interface elements by taking the source of a class-specific qml file.
Structure:
model:
incident (base)
--> incidentA (derived)
--> incidentB (derived)
--> incidentC (derived)
interface:
incEditInterface (base)
--> incEditInterfaceA(derived)
--> incEditInterfaceB (derived)
--> incEditInterfaceC (derived)
QML
incEdit.qml
{
[base class stuff]
Loader.source = "interfaceA.qml"
[additional base class stuff]
}
The actual qml code is this one (destilled for readability):
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2
[imports]
Flickable {
id: incEditFlickable
[Layout/Size stuff]
Item {
id: incEditBaseItem
[Layout/Size stuff]
property string pupilDisplayNameComposition: IncEditInterface.pupilFullName + " ("+ priv.nick + priv.gender + ")"
QtObject {
id: priv
property string nick: IncEditInterface.pupilNickName ? IncEditInterface.pupilNickName + ", " : ""
property string gender: IncEditInterface.pupilGender === Enums.MALE ? "m" : IncEditInterface.pupilGender === Enums.FEMALE ? "w" : "?"
}
// optionally overlaid dialog items ------------------------------------------------------------------------------------------------------------
Calendar {
z: 500
visible:false
id: datePickerBookedFor
[Layout/Size stuff]
onClicked: {
datePickerBookedFor.visible = false
dateButton.text = Qt.formatDate(date, "ddd dd.MM.yy")
IncEditInterface.bookedForDate = date
dateButton.shrinkToFitFromPixelSize(pupilNameSmall.font.pixelSize)
}
}
// incEditButtons -----------------------------------------------------------------------
RowLayout {
id: incEditButtonRow
[Layout/Size stuff]
CustomIconPushButton {
id: okButton
[...]
}
CustomIconPushButton {
id: adoptButton
[...]
}
CustomIconPushButton {
id: resetButton
[Layout/Size stuff]
text: "Reset"
onPushButtonClicked: {
IncEditInterface.resetEntries()
}
}
CustomIconPushButton {
id: deleteButton
[...]
}
}
// small version of incEdit header --------------------------------------------------------------------------------------------------------------
Rectangle {
id: smallTopItem
[Layout/Size stuff]
visible: true
Rectangle {
id: pupilNameSmallRect
[Layout/Size stuff]
Text {
id: pupilNameSmall
[Layout/Size stuff]
text: incEditBaseItem.pupilDisplayNameComposition
}
}
CustomIconPushButton {
id: showHideTitle1
visible: true
[Layout/Size stuff]
text: "s"
onPushButtonClicked: {
smallTopItem.visible = false;
largeTopItem.visible = true;
}
}
}
// large version of incEdit header --------------------------------------------------------------------------------------------------------------
Rectangle {
id: largeTopItem
[Layout/Size stuff]
visible: false
Rectangle {
id: pupilNameLargeRect
color: "transparent"
[Layout/Size stuff]
Image {
id: pupilPicture
[Layout/Size stuff]
source: IncEditInterface.pupilCustomPictureFileName === "" ? "" : IncEditInterface.paths.customPicturePath+IncEditInterface.pupilCustomPictureFileName
fillMode: Image.PreserveAspectFit
}
Text {
id: pupilNameLarge
[Layout/Size stuff]
text: incEditBaseItem.pupilDisplayNameComposition
}
SetCombo {
Component.onCompleted: {
groupCombo.currentIndex = groupCombo.find(IncEditInterface.groupName)
}
id: groupCombo
enabled: !datePickerBookedFor.visible
[Layout/Size stuff]
model: IncEditInterface.groupNames
textRole: "text"
onCurrentTextChanged: {
IncEditInterface.groupName = groupCombo.currentText
}
}
CustomIconPushButton {
id: dateButton
[Layout/Size stuff]
text: Qt.formatDate(IncEditInterface.bookedForDate, "ddd dd.MM.yy")
onPushButtonClicked: {
datePickerBookedFor.visible = true
}
}
CustomIconPushButton {
id: showHideTitle2
[Layout/Size stuff]
text: "h"
onPushButtonClicked: {
smallTopItem.visible = true;
largeTopItem.visible = false;
}
}
} //pupilNameLargeRect
} //largeTopItem
Loader {
id: incEditLoader
[Layout/Size stuff]
source: IncEditInterface.loaderSourceUrl
}
SetTextAreaInput {
id: additionalInfoTextInput
[Layout/Size stuff]
title: "Bemerkungen:"
text: IncEditInterface.additionalInfo
onTextChanged: IncEditInterface.additionalInfo = text
}
} //FlickableBaseItem
}
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2
[imports]
Flickable {
id: incEditFlickable
[Layout/Size stuff]
Item {
id: incEditBaseItem
[Layout/Size stuff]
property string pupilDisplayNameComposition: IncEditInterface.pupilFullName + " ("+ priv.nick + priv.gender + ")"
QtObject {
id: priv
property string nick: IncEditInterface.pupilNickName ? IncEditInterface.pupilNickName + ", " : ""
property string gender: IncEditInterface.pupilGender === Enums.MALE ? "m" : IncEditInterface.pupilGender === Enums.FEMALE ? "w" : "?"
}
// optionally overlaid dialog items ------------------------------------------------------------------------------------------------------------
Calendar {
z: 500
visible:false
id: datePickerBookedFor
[Layout/Size stuff]
onClicked: {
datePickerBookedFor.visible = false
dateButton.text = Qt.formatDate(date, "ddd dd.MM.yy")
IncEditInterface.bookedForDate = date
dateButton.shrinkToFitFromPixelSize(pupilNameSmall.font.pixelSize)
}
}
// incEditButtons -----------------------------------------------------------------------
RowLayout {
id: incEditButtonRow
[Layout/Size stuff]
CustomIconPushButton {
id: okButton
[...]
}
CustomIconPushButton {
id: adoptButton
[...]
}
CustomIconPushButton {
id: resetButton
[Layout/Size stuff]
text: "Reset"
onPushButtonClicked: {
IncEditInterface.resetEntries()
}
}
CustomIconPushButton {
id: deleteButton
[...]
}
}
// small version of incEdit header --------------------------------------------------------------------------------------------------------------
Rectangle {
id: smallTopItem
[Layout/Size stuff]
visible: true
Rectangle {
id: pupilNameSmallRect
[Layout/Size stuff]
Text {
id: pupilNameSmall
[Layout/Size stuff]
text: incEditBaseItem.pupilDisplayNameComposition
}
}
CustomIconPushButton {
id: showHideTitle1
visible: true
[Layout/Size stuff]
text: "s"
onPushButtonClicked: {
smallTopItem.visible = false;
largeTopItem.visible = true;
}
}
}
// large version of incEdit header --------------------------------------------------------------------------------------------------------------
Rectangle {
id: largeTopItem
[Layout/Size stuff]
visible: false
Rectangle {
id: pupilNameLargeRect
color: "transparent"
[Layout/Size stuff]
Image {
id: pupilPicture
[Layout/Size stuff]
source: IncEditInterface.pupilCustomPictureFileName === "" ? "" : IncEditInterface.paths.customPicturePath+IncEditInterface.pupilCustomPictureFileName
fillMode: Image.PreserveAspectFit
}
Text {
id: pupilNameLarge
[Layout/Size stuff]
text: incEditBaseItem.pupilDisplayNameComposition
}
SetCombo {
Component.onCompleted: {
groupCombo.currentIndex = groupCombo.find(IncEditInterface.groupName)
}
id: groupCombo
enabled: !datePickerBookedFor.visible
[Layout/Size stuff]
model: IncEditInterface.groupNames
textRole: "text"
onCurrentTextChanged: {
IncEditInterface.groupName = groupCombo.currentText
}
}
CustomIconPushButton {
id: dateButton
[Layout/Size stuff]
text: Qt.formatDate(IncEditInterface.bookedForDate, "ddd dd.MM.yy")
onPushButtonClicked: {
datePickerBookedFor.visible = true
}
}
CustomIconPushButton {
id: showHideTitle2
[Layout/Size stuff]
text: "h"
onPushButtonClicked: {
smallTopItem.visible = true;
largeTopItem.visible = false;
}
}
} //pupilNameLargeRect
} //largeTopItem
Loader {
id: incEditLoader
[Layout/Size stuff]
source: IncEditInterface.loaderSourceUrl
}
SetTextAreaInput {
id: additionalInfoTextInput
[Layout/Size stuff]
title: "Bemerkungen:"
text: IncEditInterface.additionalInfo
onTextChanged: IncEditInterface.additionalInfo = text
}
} //FlickableBaseItem
}
To copy to clipboard, switch view to plain text mode
Bookmarks