Results 1 to 7 of 7

Thread: QFrame parent, QGLWidget-based child

  1. #1
    Join Date
    Feb 2006
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QFrame parent, QGLWidget-based child

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QFrame parent, QGLWidget-based child

    The subject of the post is wrong, its about mouse grabbing not parent child problems.
    Did you call setMouseTracking() for your widget?

  3. #3
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFrame parent, QGLWidget-based child

    @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.
    Save yourself some pain. Learn C++ before learning Qt.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QFrame parent, QGLWidget-based child

    BTW, @high_flyer, setMouseTracking() is only required if you want to capture mouse move events.
    You are right, I stand corrected.

  5. #5
    Join Date
    Feb 2006
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFrame parent, QGLWidget-based child

    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

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QFrame parent, QGLWidget-based child

    'e' needs to be a pointer:
    Qt Code:
    1. void CTHV::mousePressEvent(QMouseEvent *e)
    2. {
    3. printf("Mouse Press Event!\n");
    4. }
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Feb 2006
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFrame parent, QGLWidget-based child

    excellent. Thanks for catching my typo

    many eyes...

    /bow

Similar Threads

  1. Replies: 1
    Last Post: 28th July 2006, 14:10
  2. initialize child widgets within parent?
    By ucomesdag in forum Newbie
    Replies: 6
    Last Post: 6th June 2006, 08:11
  3. Move child widget along with the parent widget
    By sreedhar in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2006, 12:00
  4. Infinite loop - resize parent from child
    By bitChanger in forum Qt Programming
    Replies: 3
    Last Post: 5th May 2006, 13:21
  5. Referencing Parent Widget from Child
    By taylor34 in forum Qt Programming
    Replies: 8
    Last Post: 11th April 2006, 15:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.