While making connection the oder and type of the parameters in the signature of the slot and signal should be same. Note that QPoint and const QPoint are considered as different types. This you could have figured out by looking at the warning messages in application output.
//cabletreewidget.h
#ifndef CABLETREEWIDGET_H
#define CABLETREEWIDGET_H
#include <QTreeWidget>
{
Q_OBJECT
public:
CableTreeWidget();
~CableTreeWidget();
private:
protected slots:
void ShowContextMenu
(const QPoint & );
//<<<<<<<<<<< added const
};
#endif // CABLETREEWIDGET_H
//cabletreewidget.h
#ifndef CABLETREEWIDGET_H
#define CABLETREEWIDGET_H
#include <QTreeWidget>
class CableTreeWidget : public QTreeWidget
{
Q_OBJECT
public:
CableTreeWidget();
~CableTreeWidget();
private:
protected slots:
void ShowContextMenu(const QPoint & ); //<<<<<<<<<<< added const
};
#endif // CABLETREEWIDGET_H
To copy to clipboard, switch view to plain text mode
//cabletreewidget.cpp
#include "cableTreeWidget.h"
#include <QtCore>
#include <QMenu>
CableTreeWidget::CableTreeWidget()
{
this->setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(ShowContextMenu(const QPoint&))); //<<<<<<<<<<< added const
}
CableTreeWidget::~CableTreeWidget()
{
}
void CableTreeWidget
::ShowContextMenu(const QPoint &pos
) //<<<<<<<<<<< added const {
QPoint globalPos
= this
->mapToGlobal
( pos
);
myMenu.addAction("Menu Item 1");
// ...
QAction* selectedItem
= myMenu.
exec(globalPos
);
}
//cabletreewidget.cpp
#include "cableTreeWidget.h"
#include <QtCore>
#include <QMenu>
CableTreeWidget::CableTreeWidget()
{
this->setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(ShowContextMenu(const QPoint&))); //<<<<<<<<<<< added const
}
CableTreeWidget::~CableTreeWidget()
{
}
void CableTreeWidget::ShowContextMenu(const QPoint &pos) //<<<<<<<<<<< added const
{
QPoint globalPos = this->mapToGlobal( pos );
QMenu myMenu;
myMenu.addAction("Menu Item 1");
// ...
QAction* selectedItem = myMenu.exec(globalPos);
}
To copy to clipboard, switch view to plain text mode
Bookmarks