PDA

View Full Version : problem propagating mouse events.



ngc_1729
28th July 2010, 05:54
Hi I have a base class: GLWidget that inherits from QGLWidget:

class GLWidget : public QGLWidget
{
Q_OBJECT
---
---
protected:
void initializeGL();
void paintGL();
void resizeGL(int width, int height);

virtual void mousePressEvent(QMouseEvent *event) {
std::cout<<"GLWidget mousePressEvent"<<std::endl;
}

virtual void mouseMoveEvent(QMouseEvent *event);
};

Then I am deriving another class from GLWidget like so :

class A : public GLWidget
{
Q_OBJECT
public:
A(QWidget* parent = 0);
virtual ~A();
protected:
virtual void mousePressEvent(QMouseEvent *event) {
std::cout<<"A::mousePressEvent"<<std::endl;
}

};

now in my mainwindow.cpp, I instantiate my GLWidget and A objects.

My question is how can I make my A::mousePressEvent() to be called? everytime I press my mouse on my mainWindow, my GLWidget::mousePressEvent is called. I want my A::mousePressEvent to be called. Could some one please help me?

I called event->igonore in my GLWidget::mousePressEvent() but of no use.

Thanks in advance.

Venu

agathiyaa
28th July 2010, 15:11
Post some more code to figure out the issue. your code isn't enough .


everytime I press my mouse on my mainWindow, my GLWidget::mousePressEvent is called

How did you do the above ?