Results 1 to 3 of 3

Thread: How to add right click actions?

  1. #1
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question How to add right click actions?

    Hello all, I want to have a On_item_right_clicked action on a listwidget but unfortunately there is no such slot. Can you show me the right way of materializing this?
    For instance, I want when to right click on an Item of the listwidget to have a menu with some options and then these options to be connected with some other slot that guides to a void function
    When you 're trying to help somebody in the newbie section, don't forget that he is a newbie. Be specific and give examples.

  2. #2
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to add right click actions?

    Ok, i've found a kind of solution but i haven't understand very well..
    I feel that I'm saying a simple thing: I am using designer. I do right click on the listwidget and I go to slot-> customContextMenuRequested(QPoint pos);What code should I place there so to have a menu on right click?
    When you 're trying to help somebody in the newbie section, don't forget that he is a newbie. Be specific and give examples.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to add right click actions?

    A few calls to QWidget::addAction() and then QWidget::setContextMenuPolicy() with Qt::ActionsContextMenu. No need to override the context menu event handler unless you have something more complicated to do there.

Similar Threads

  1. Replies: 2
    Last Post: 8th December 2009, 17:33
  2. Replies: 6
    Last Post: 5th June 2009, 09:38
  3. Replies: 2
    Last Post: 11th January 2009, 23:24
  4. QGraphicsScene Click / Double Click
    By philentropist in forum Qt Programming
    Replies: 1
    Last Post: 9th February 2007, 04:32
  5. Replies: 5
    Last Post: 12th January 2006, 15:40

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
  •  
Qt is a trademark of The Qt Company.