Results 1 to 1 of 1

Thread: QListWidgetItem - context menu

  1. #1

    Default Re: QListWidgetItem - context menu

    I have successfully created a context-menu for my QListWidget. However, what I want is a context-menu per item. Now, I can check the selected item and change the context-menu based on this, but, what I really need is to know the active item. I want a standard menu as well as a item-specific menu. So, if the user right-clicks on the QListWidget one menu appears, but if they right-click on a specific item instead, that item's menu appears. How would I go about this?


    Added after 8 minutes:


    Figured this one out:
    Qt Code:
    1. QListWidgetItem* temp = itemAt(point);
    2. if(temp != NULL)
    To copy to clipboard, switch view to plain text mode 

    When using itemAt with a QListWidgetItem you can determine the item at the cursor position. If NULL is returned then no item was specifically clicked. This gives you the active item rather than the selected.
    Last edited by QT8seven; 14th December 2011 at 02:42.

Similar Threads

  1. Replies: 1
    Last Post: 4th November 2011, 11:25
  2. Add a dropdown menu to QListWidgetItem
    By plan_rich in forum Newbie
    Replies: 2
    Last Post: 7th September 2010, 16:17
  3. QListWidgetItem popup menu on right mouse click
    By AcerExtensa in forum Qt Programming
    Replies: 1
    Last Post: 10th June 2010, 13:17
  4. Qwt and context menu
    By giusepped in forum Qwt
    Replies: 1
    Last Post: 9th December 2008, 08:55
  5. Context Menu
    By RY in forum Newbie
    Replies: 1
    Last Post: 10th September 2008, 07:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.