September 7, 2011

Adi Adi
Lab Rat
206 posts

Regarding context menu

 

Hi All

I have created a Qwidget window on which i have place QTreeWidget.
Then i have created a context menu,& on right click of mouse i tried to show this context menu.
But I am not able to connect my signal to the slot.

SIGNAL:

  1. connect(treewidgetptr,SIGNAL(customContextMenuRequested ( const QPoint & pos ) ),this,SLOT(contextMenuEvent(QContextMenuEvent * event )));

3 replies

September 7, 2011

Johan Solo Johan Solo
Lab Rat
123 posts

The signal and the slot must have the same arguments, here you have QPoint and QContextMenuEvent types.

From the doc [doc.qt.nokia.com] : “The signals and slots mechanism is type safe: The signature of a signal must match the signature of the receiving slot.”

 Signature 

Linux : you can find worse, but it’s more expensive.

September 7, 2011

Lukas Geyer Lukas Geyer
Lab Rat
2074 posts

In addition, you should not pass any parameter names, just types.

September 7, 2011

octal octal
Lab Rat
74 posts

If your context menu is based on QAction, you just can set the contextMenuPolicy to Qt::ActionsContextMenu.

Then, all you need to do is insering your actions with QWidget::addAction [doc.qt.nokia.com]

 
  ‹‹ Method raise() of class QWidget does not work as expected      using /clr on qt ››

You must log in to post a reply. Not a member yet? Register here!