Results 1 to 1 of 1

Thread: TreeView question

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Cool TreeView question

    Hello,

    I've created main window. The central widget of main window is TreeView (see attached picture). I want to do the following: if user does right click on the item then context menu appears. Context menu's content depends on the type of the item. But when user does right click outside the item context menu doesn't appeard.

    To appear context menu I've written the following.

    Qt Code:
    1. void MainWindow::createContextMenu()
    2. {
    3. tree->addAction(newLibAction);
    4. tree->addAction(openLibAction);
    5. tree->addAction(closeLibAction);
    6. tree->setContextMenuPolicy(Qt::ActionsContextMenu);
    7. }
    To copy to clipboard, switch view to plain text mode 

    Do I need reimplement MainWindow::contextMenuEvent and depends on selected item type create context menu.

    Please, give me any advice.
    Thanks in advance.
    Attached Images Attached Images

Similar Threads

  1. licensing question
    By tommy in forum Installation and Deployment
    Replies: 4
    Last Post: 14th April 2010, 11:54
  2. Problem with auto expand on treeview
    By piquadrat in forum Qt Programming
    Replies: 1
    Last Post: 26th April 2009, 11:21
  3. Useless but curious compiler warning question
    By Raccoon29 in forum General Programming
    Replies: 4
    Last Post: 30th July 2008, 20:46
  4. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53

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.