You are not logged in.

hojtsy

Trainee

  • "hojtsy" is male
  • "hojtsy" started this thread

Posts: 65

Location: Hungary

Occupation: Software Developper

  • Send private message

1

Monday, November 21st 2005, 11:31am

context menu on QTreeView

I would like to create a context menu for a QTreeView. I tried this:

treeView->addAction( action1 );
treeView->setContextMenuPolicy(Qt::ActionsContextMenu);

My problem is that the right-click which pops up the context menu should move the selection to the right-clicked cell before the menu pops up. Just like MS excell works for example. But selection is unchanged. Is there some common solution for this? Should I set the Qt::CustomContextMenu policy, or install an event filter and do everything manually?

hatulflezet

Professional

Posts: 1,301

Location: Munich Germany

Occupation: Programmer

  • Send private message

2

Monday, November 21st 2005, 12:46pm

could you show how you implemented this?
Click here! I dare ya'!! :]
Project Archimedes
----------------------------------------------------------
"Don't panic, and thanks for all the fish!"

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

3

Monday, November 21st 2005, 1:46pm

RE: context menu on QTreeView

You might try installing an event filter and changing the selection before the menu pops up. Or handle the cotext menu event yourself. Both approaches are correct. Using context menu automade from actions limits possiblities to control the behaviour of the widget and is intended for simple menus.