Results 1 to 5 of 5

Thread: Custom QTreeWidgetItem context menu?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2007
    Posts
    14
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Custom QTreeWidgetItem context menu?

    All I really see that doing is moving the execution of the menu into QCustomTreeWidget. I would still need a way to connect the QCustomTreeWidget:nCustomAction(); slot to actCustom::triggered().

    I'll probably end up making a QObject derived class that spits out the tree-node when needed. Then I'll have something to signal/slot.

  2. #2
    Join Date
    Oct 2009
    Posts
    35
    Thanks
    12
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11

    Default Re: Custom QTreeWidgetItem context menu?

    Hi,u try this below code

    //action method.
    void XXXX::XXX()
    {


    action_New = new QAction("&New", ui->treeWidget);
    action_Open = new QAction("&Open", ui->treeWidget);

    //add the code at slots
    connect(action_New, SIGNAL(triggered()), this, SLOT(on_action_New_triggered()));
    connect(action_Open, SIGNAL(triggered()), this, SLOT(on_action_Open_triggered()));


    ui->treeWidget->addAction(action_New);
    ui->treeWidget->addAction(action_Open);
    ui->treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);

    }

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom QTreeWidgetItem context menu?

    I guess one could also useQTreeWidget::itemClicked to provide menus for items.

Similar Threads

  1. Context Menu on QTableWidget
    By ankurjain in forum Qt Programming
    Replies: 9
    Last Post: 17th December 2009, 09:52
  2. Replies: 4
    Last Post: 25th June 2007, 20:40
  3. Misplaced Context Menu
    By kandalf in forum Qt Programming
    Replies: 6
    Last Post: 18th February 2007, 04:28
  4. image for a custom menu Item.......
    By Naveen in forum Qt Programming
    Replies: 2
    Last Post: 23rd February 2006, 09:28
  5. Q3TextEdit custom context menu
    By bcteh_98 in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2006, 21:00

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.