{
Q_OBJECT
Q_CLASSINFO("version", "1.0.0");
public:
MyScene
(VPFPrimitives
* primitives,
QObject* parent
= 0);
~MyScene() {}
protected:
void vCreateContextMenuConnections();
private:
VPFPrimitives* m_VPFPrimitives;
friend class FundGC;
};
{
Q_OBJECT
Q_CLASSINFO("version", "1.0.0");
public :
~GC();
private:
MyScene* m_scene;
VPFPrimitives* m_VPFPrimitives;
private slots:
void vZoom();
};
class MyScene: public QGraphicsScene
{
Q_OBJECT
Q_CLASSINFO("version", "1.0.0");
public:
MyScene(VPFPrimitives* primitives, QObject* parent = 0);
~MyScene() {}
protected:
void contextMenuEvent( QGraphicsSceneContextMenuEvent * contextMenuEvent);
void vCreateContextMenuConnections();
private:
VPFPrimitives* m_VPFPrimitives;
QMenu* m_contextMenu;
QAction* m_actionContextZI;
friend class FundGC;
};
class GC: public QWidget
{
Q_OBJECT
Q_CLASSINFO("version", "1.0.0");
public :
GC(QGraphicsView*,QWidget* parent = 0);
~GC();
private:
MyScene* m_scene;
VPFPrimitives* m_VPFPrimitives;
private slots:
void vZoom();
};
To copy to clipboard, switch view to plain text mode
And the implementation:
{
m_VPFPrimitives = primitives;
vCreateContextMenuConnections();
}
/*! Creating context menu for the graphics Scene*/
{
m_contextMenu
= new QMenu();
/*!< Context Menu */ m_actionContextZI
= new QAction("Zoom In",
this);
m_contextMenu->addAction(m_actionContextZI);
m_contextMenu->exec(contextMenuEvent->screenPos());
}
void MyScene::vCreateContextMenuConnections()
{
connect(m_actionContextZI,SIGNAL(triggered()),this->parent(),SLOT(this->parent()->vZoom()));
}
void GC::vZoom()
{
}
MyScene::MyScene(VPFPrimitives* primitives,QObject* parent): QGraphicsScene(parent)
{
m_VPFPrimitives = primitives;
vCreateContextMenuConnections();
}
/*! Creating context menu for the graphics Scene*/
void MyScene::contextMenuEvent( QGraphicsSceneContextMenuEvent * contextMenuEvent)
{
m_contextMenu = new QMenu();/*!< Context Menu */
m_actionContextZI = new QAction("Zoom In",this);
m_contextMenu->addAction(m_actionContextZI);
m_contextMenu->exec(contextMenuEvent->screenPos());
}
void MyScene::vCreateContextMenuConnections()
{
connect(m_actionContextZI,SIGNAL(triggered()),this->parent(),SLOT(this->parent()->vZoom()));
}
void GC::vZoom()
{
QMessageBox::warning(this,"yes","working");
}
To copy to clipboard, switch view to plain text mode
The code is quite long; I have pasted the most important parts
Bookmarks