Monday, April 29, 2024
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 1591  / 2 Years ago, tue, march 8, 2022, 9:35:03

If i use the PopupUtils.open() command in the Component.onCompleted property of the any item it does nothing, example:



Rectangle {
id: rect
height: 600
width: height
Component.onCompleted: {
PopupUtils.open(dialog, rect)
}

Component {
id: dialog
Dialog {
id: dialogue
title: "Save file"
text: "Are you sure that you want to save this file?"
Button {
text: "cancel"
onClicked: PopupUtils.close(dialogue)
}
Button {
text: "overwrite previous version"
color: "orange"
onClicked: PopupUtils.close(dialogue)
}
Button {
text: "save a copy"
color: "orange"
onClicked: PopupUtils.close(dialogue)
}
}
}


how can i properly display a popup dialog just after the app has started?


More From » application-development

 Answers
7

For some reason, it works using a Timer, ie:



Rectangle {
id: rect
height: 600
width: height
Component.onCompleted: {
start_timer.start()
}

Timer {
id: start_timer
interval: 200;
onTriggered: PopupUtils.open(dialog, rect)
}

Component {
id: dialog
Dialog {
id: dialogue
title: "Save file"
text: "Are you sure that you want to save this file?"
Button {
text: "cancel"
onClicked: PopupUtils.close(dialogue)
}
Button {
text: "overwrite previous version"
color: "orange"
onClicked: PopupUtils.close(dialogue)
}
Button {
text: "save a copy"
color: "orange"
onClicked: PopupUtils.close(dialogue)
}
}
}

[#31716] Wednesday, March 9, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cocal

Total Points: 236
Total Questions: 111
Total Answers: 123

Location: Belarus
Member since Tue, Mar 14, 2023
1 Year ago
;