Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Yuya Nishihara
quick-controls-menu
Commits
92d6272e
Commit
92d6272e
authored
May 15, 2020
by
Yuya Nishihara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add example of dynamic menu registration
parent
af5e2c6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
main.qml
main.qml
+46
-0
No files found.
main.qml
View file @
92d6272e
...
...
@@ -2,6 +2,8 @@ import QtQuick 2.12
import
QtQuick
.
Controls
2.12
ApplicationWindow
{
id
:
window
visible
:
true
width
:
640
height
:
480
...
...
@@ -15,4 +17,48 @@ ApplicationWindow {
Action
{
text
:
qsTr
(
"
&Quit
"
)
}
}
}
// Instantiated statically, but registered dynamically
Menu
{
id
:
debugMenu
visible
:
false
title
:
qsTr
(
"
&Debug
"
)
Action
{
text
:
qsTr
(
"
Static action
"
)
}
}
// Instantiated dynamically
Component
{
id
:
dynamicMenuComponent
Menu
{
visible
:
false
title
:
qsTr
(
"
D&aynamic
"
)
Action
{
text
:
qsTr
(
"
Static action
"
)
}
}
}
Action
{
id
:
dynamicallyRegisteredAction
text
:
qsTr
(
"
Dynamically registered action
"
)
}
Component.onCompleted
:
{
window
.
menuBar
.
addMenu
(
debugMenu
);
}
Timer
{
running
:
true
interval
:
2000
onTriggered
:
{
let
menu
=
dynamicMenuComponent
.
createObject
(
window
);
window
.
menuBar
.
addMenu
(
menu
);
}
}
Timer
{
running
:
true
interval
:
4000
onTriggered
:
{
debugMenu
.
addAction
(
dynamicallyRegisteredAction
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment