Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [Solved] QMenu item/action pre selection

    General and Desktop
    2
    3
    2641
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      Sam last edited by

      I am using a contextMenu and just want to know if there is any possibility that when the contextMenu is displayed a particular item/action is represented as selected, just like a QListView/QListWidget.

      TIA

      1 Reply Last reply Reply Quote 0
      • T
        tzander last edited by

        a context menu is build up of QMenu items, which essentially are buttons.
        You can use the cursor keys, but it sounds odd to 'pre-select' something. Its not a selectable thing.

        What you may be thinking of is that you position the menu such that the item you want is under the cursor. And this you can do yourself, you just use the QPoint you pass when popping up the menu. Calculate the offset to your wanted item (based on the height of the buttons), and subtract that from the popup position.

        1 Reply Last reply Reply Quote 0
        • S
          Sam last edited by

          Thanks Thomas,

          For the current requirement the contextMenu is associated with a pushButton i.e the position of the context menu is fixed, The button hold some property which is listed in the contextMenu, So when the contextMenu is displayed the current property of the pushButton is shown as selected in the menu, the user can change the property by selecting other items from the same.

          I have another implementation where I am using a listWidget that shows all properties and is added using QWidgetAction to the contextMenu. This implementation works as required, so i think i'll stick to this as of now.

          Regards,
          Soumitra

          1 Reply Last reply Reply Quote 0
          • First post
            Last post