Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] QMenu item/action pre selection
QtWS25 Last Chance

[Solved] QMenu item/action pre selection

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.0k Views
  • 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 Offline
    S Offline
    Sam
    wrote on last edited by
    #1

    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
    0
    • T Offline
      T Offline
      tzander
      wrote on last edited by
      #2

      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
      0
      • S Offline
        S Offline
        Sam
        wrote on last edited by
        #3

        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
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved