PDA

View Full Version : Dialog on right click on windows?



vishal.chauhan
4th August 2008, 06:55
Hi All,

I am working on Qt 4.3.4 on my Windows.
I have a QTreeWidget of items and I want to show a dialog when user right click on that item.
How to do it?

Plz help me out.

Thanks.
Vishal

Ginsengelf
4th August 2008, 06:59
Hi,

connect qtreewidget.html#itemClicked to a custom slot and there create your dialog.

Ginsengelf

vishal.chauhan
4th August 2008, 07:03
But it will work on either click (right or left).
But Actually I want to implement the right click property of windows.

jpn
4th August 2008, 07:23
Do you mean "context menu"? If so, search the forums, please.

vishal.chauhan
4th August 2008, 07:41
Yes I am talking about context menu.
Thanks.

spirit
4th August 2008, 09:36
first, set next property for widget for which context menu is needed.

yourWidget->setContextMenuPolicy(Qt::CustomContextMenu)

then,


connect(yourWidget, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(yourContextMenuDisplayMethod(const QPoint &)));


and last you need to show context menu in
yourContextMenuDisplayMethod(const QPoint &).