PDA

View Full Version : QGraphicsView mousePressEvent -- how to setup the signal and slots?



jiapei100
14th May 2010, 01:48
Hi, all:

I created a class "CqtImageView" which inherits from QGraphicsView, in which I overwrite mousePressEvent



class CqtImageView : public QGraphicsView
{
...
void mousePressEvent(QMouseEvent *event);
...
}


One "CqtImageView" object is further created in the "Ui" of my main class,


class CMyMain : public QMainWindow
{
...
Ui::mymainClass ui;
...
}
this ui contains a "CqtImageView" widget.


I would like to count the mouse pressed times over the CqtImageView in CMyMain class.
Therefore, I may need an signal-slot to inform CMyMain when mousePressEvent happens.

How to?

Cheers
JIA

aamer4yu
14th May 2010, 06:14
Therefore, I may need an signal-slot to inform CMyMain when mousePressEvent happens.
You are right there..
from the CqtImageView ::mousePressEvent emit a custom signal
emit viewPressed(); you can also have a internal count and may have a signal like
void viewPressed(int /*count*/);

Then in main window I guess you know how to connect signal-slots , right ?