(How) Can i use ContextMenu in something other than a ListView?

First of all, should it be usable in something that is not a ListView?
The documentation seems to hint at it, but does not really give much to go on.

To me the natural candidate is a Column, with e.g. BackgroundItem in, which i have tried… but can’t get to work.
Are there any example usages of ContextMenu outside a ListView?

Hi. I am using ContextMenu in generic Rectangle and it is working without problem for me: https://github.com/Karry/osmscout-sailfish/blob/master/qml/pages/MapPage.qml#L852

nextStepBox is transparent Rectangle, it is visible when navigation is in progress. Its height is summary of heights its childs nextStepBackground and navigationContextMenu. nextStepBackground contains MouseArea (nextStepMouseArea) that activates context menu on onPressAndHold action…

Thanks for the hint!
I’m afraid i’m still lost. I need to do it for multiple items that are arranged vertically, and it seems a Recatangle does not care about being placed in a column.

I guess i could use rectangles and anchor all the things to eachother… and make the flickable height the sum of all items.
But it feels like a cludge, and not really better than the current solution.

I’m trying to improve this madness:

Well, in your case, it needs a bit bigger refactoring. You cannot use anchor or relative positioning in Column or Row. And Setting item have to have specified its height…

Here is merge request with refactored page: https://github.com/attah/harbour-seaprint/pull/43
I don’t test it deeply, but UI seems to be working…

3 Likes

Thank you very much!
I am sorry you had to sift through the pile of … that is my code.
It looks much better now. I have built it, and from what i can see it works more than well enough to just merge.

You are welcome :wink: Thank you for Seaprint!

1 Like