PDA

View Full Version : QFrame parent, QGLWidget-based child



philski
28th August 2006, 17:40
hey folks,

I have a custom widget based off of a QGLWidget.

I set the widget's parent equal to a QFrame:

DrawWindow = new CTHV( myQFrame, 0, this);

and the widget shows up just fine on screen.

My problem is this: I can't get the QGLWidget to catch mouse clicks/keyboard events. The focus policy is set to QWidget::WheelFocus.

I've tried using setFocusProxy(DrawWindow) and it didn't work either.

Any ideas?

Thanks,

philski

high_flyer
28th August 2006, 18:00
The subject of the post is wrong, its about mouse grabbing not parent child problems.
Did you call setMouseTracking() for your widget?

Chicken Blood Machine
28th August 2006, 18:36
@philski - Did you subclass QGLWidget in order to override the mouse press and key events? Also, The setting of the focus policy is not important here.

BTW, @high_flyer, setMouseTracking() is only required if you want to capture mouse move events.

high_flyer
28th August 2006, 18:41
BTW, @high_flyer, setMouseTracking() is only required if you want to capture mouse move events.
You are right, I stand corrected.

philski
28th August 2006, 18:54
Chicken Blood:

My QGLWidget has a mousePressEvent() handler that simply writes to console when activated:


void CTHV::mousePressEvent(QMouseEvent e)
{
printf("Mouse Press Event!\n");
}

but it never appears.

-philski

high_flyer
28th August 2006, 18:58
'e' needs to be a pointer:

void CTHV::mousePressEvent(QMouseEvent *e)
{
printf("Mouse Press Event!\n");
}

philski
28th August 2006, 19:14
excellent. Thanks for catching my typo :)

many eyes...

/bow