I am adding a popup menu to my QtQuick GUI (as in here I believe) and it does not behave as I had expected.
Here is what I do:
import QtQuick 2.7
import QtQuick.Layouts 1.3
import QtQuick.Window 2.2
import QtQuick.Controls 2.0
import QtQuick.Controls.Styles 1.2
ApplicationWindow
{
...
// File menu button.
Rectangle
{
id: ribbonFileMenuButton
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
width: height
height: parent.height
scale: ribbonFileMenuButtonMA.pressed ? 1.3 : 1
color: "transparent"
// Icon.
RibbonFileButtonIcon
{
id: ribbonFileMenuButtonIcon
anchors.fill: parent
}
// Behavior.
MouseArea
{
id: ribbonFileMenuButtonMA
anchors.fill: parent
onClicked: menu.open() /*popup()*/
}
}
...
// File.
Menu
{
id: menu
y: 20
MenuItem
{
text: "New..."
}
MenuItem
{
text: "Open..."
}
// MenuSeparator { }
MenuItem
{
text: "Save"
}
}
...
}
First, I have to call menu.open() and not menu.popup() (as described in the doc indicated in the above provided link): menu.popup() outputs error:
TypeError: Property 'popup' of object QQuickMenu(0x20f40f0) is not a function
Then if I uncomment MenuSeparator { }, I get the following error:
MenuSeparator is not a type
Again, according to the doc in the provided link, it should work.
I have looked over the internet, but I am a bit lost...
Thanks,
Antoine.