Opening a ContextMenu placed in another file
I am trying to isolate ContextMenus, which are somewhat generic, i.e., have Edit+Delete options into a standalone QML file.
Simple question: how does one invoke the open() method from the Qt Component reference. The following code is [B]wrong[/B], but you can get a sense of what I am trying to do:
[CODE] onPressAndHold: ProjectContextMenu {}.open()[/CODE]
I had also tried the basic:
[CODE] onPressAndHold: ProjectContextMenu {}[/CODE]
but this results in the error:
[CODE]Cannot assign object type ContextMenu_QMLTYPE_57 with no default method[/CODE]
advTHANKSance
Re: Opening a ContextMenu placed in another file
To me it looks like you are creating QML Context menu component and trying to open it. I dont think this way QML works. I suggest you to create context menu element in your current QML and use id to open it. like
MouseArea {
id: longPressArea
anchors.fill: parent
onPressAndHold: myContextMenu.open()
}
}
check this link here
[url]http://harmattan-dev.nokia.com/docs/library/html/qt-components/qt-components-meego-contextmenu.html[/url]
Re: Opening a ContextMenu placed in another file
You are quite correct. I am trying to isolate common elements much as one would do by declaring other Qt Components in external files. But I gather that QML isn't designed to do this for every component.
Are there specific `types' of components where it make sense to put into another file, e.g., visual only?
Thanks.
Re: Opening a ContextMenu placed in another file
I remember doing something like
ExternalContextmenu{
id: externalmenu
}
on some,
onClicked: {
externalmenu.open()
}
ExternalContextmenu.qml will contain the actual ContextMenu representation..
-CK
Re: Opening a ContextMenu placed in another file
But I thought that [B]id[/B] is not visible outside of the local file, so wouldn't the [B]externalmenu.open()[/B] invocation would fail as a consequence?
Re: Opening a ContextMenu placed in another file
As,
ExternalContextmenu{
id: externalmenu
}
is going to be in ur local qml file, its gonna be the local instance.. isnt it ?
-CK