Nominate our 2022 Qt Champions!

How to show Context menu in Desktop QML

  • Hi,

    I am following Christophe Dumez("") in my application.
    Now i want to display context menu in my QML. And item in context menu will be condition based e.g. if i click left button then there is only one item("One Item") & if i click right button then there will be two items("One Item ", Two Item). So can you please suggest me how to make context menu in my QML.(Provide me any example link)

  • Hi,
    That's not so hard to implement it. Write your own custom context menu (an item with some buttons put them in column and also you can implement mouse hover for buttons) then in mouse area of qml, implement right and left click to show your desired context menu.

  • Hi,
    I am able to display context menu, but my question is that how to show context menu condition based as i wrote in first post?

  • in mouse area base on which mouse button clicks (left or right click)you can emit a signal or change a property, after that you can bind this property to show your favorite context menu. That's so easy , am i clear?

Log in to reply