Results 1 to 3 of 3

Thread: Two context menu for a treewidget

  1. #1
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Two context menu for a treewidget

    Hi All,
    I ve a tree widget. If i right click on that treewidget, a contextmenu is poping up. I've added two action to that context menu, Add parent and Add child. Afetr adding parents and children to perticular parent, if i right click on a child or parent I need a new popup action which should ask If i want to delete parent. How to do this.? plz help me.
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Two context menu for a treewidget

    Reimplement QWidget::contextMenuEvent() and use QAbstractItemView::indexAt() to check the index that was clicked or use the one that was current (QAbstractItemView::currentIndex()), detect what kind of item is that and do your stuff accordingly.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Two context menu for a treewidget

    Quote Originally Posted by wysota View Post
    Reimplement QWidget::contextMenuEvent() and use QAbstractItemView::indexAt() to check the index that was clicked or use the one that was current (QAbstractItemView::currentIndex()), detect what kind of item is that and do your stuff accordingly.
    Thank u. I'll try this way.
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

Similar Threads

  1. Context Menu on QTableWidget
    By ankurjain in forum Qt Programming
    Replies: 9
    Last Post: 17th December 2009, 09:52
  2. Context Menu for specific items in a Tree Widget
    By manekineko in forum Qt Programming
    Replies: 0
    Last Post: 16th November 2009, 01:46
  3. problem in treewidget context menu
    By phillip_Qt in forum Qt Programming
    Replies: 1
    Last Post: 12th November 2009, 11:11
  4. Shortcut key for context menu
    By darshan.hardas in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2008, 20:32
  5. Replies: 4
    Last Post: 25th June 2007, 20: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.