Results 1 to 5 of 5

Thread: overridden QAxWidget::translateKeyEvent(int message, int keycode) not being called

  1. #1
    Join Date
    Sep 2008
    Posts
    4
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default overridden QAxWidget::translateKeyEvent(int message, int keycode) not being called

    I use QAxWidget to wrap an ActiveX control, since the container QWidget needs to customize the KeyPressEvent, so I have inherited from QAxWidget and overridden translateKeyEvent(int message, int keycode), but this function never called. here is the codes:

    class CXXXAxWidget : public QAxWidget
    {
    public:
    CXXXAxWidget(QWidget* parent = 0, Qt::WindowFlags f = 0)
    : QAxWidget(parent, f)
    {
    }
    protected:
    virtual bool translateKeyEvent(int message, int keycode) const;
    };

    bool CXXXAxWidget::translateKeyEvent(int message, int keycode) const
    {
    //log

    if (message == WM_KEYDOWN)
    return true;
    else
    return QAxWidget::translateKeyEvent(message, keycode);
    }

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,243
    Thanks
    303
    Thanked 866 Times in 853 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: overridden QAxWidget::translateKeyEvent(int message, int keycode) not being calle

    Do you see any events for your ActiveX control? Like mouse events, for example? May be you need to enable the CXXXAxWidget (myWidget->setEnabled( true ))?

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: overridden QAxWidget::translateKeyEvent(int message, int keycode) not being calle

    Please us [code] [/code] tags around code.

    From the QAxWidget docs:
    However, you cannot reimplement Qt-specific event handlers like mousePressEvent or keyPressEvent and expect them to be called reliably. The embedded control covers the QAxWidget completely, and usually handles the user interface itself. Use control-specific APIs (i.e. listen to the signals of the control), or use standard COM techniques like window procedure subclassing.
    A version of same question has been asked in the recent past:
    http://www.qtcentre.org/threads/4096...ight=qaxwidget

  4. #4
    Join Date
    Sep 2008
    Posts
    4
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: overridden QAxWidget::translateKeyEvent(int message, int keycode) not being calle

    ChrisW67, thanks for the help, I did read the document and I know the Qt event might not be reliable to be called. but right now my question is the QAxWidget::translateKeyEvent(...) should be called if we override it, right? but I could not see it is called by tracing the program. any advise, thanks in advance.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: overridden QAxWidget::translateKeyEvent(int message, int keycode) not being calle

    Yes, given that it is part of QAxWidget and not the underlying QWidget interface, I guess it should. Your declaration seems sound, ie. correct signature.

    Is the wrapped control common? Could you post a small compilable example that doesn't work?
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

Similar Threads

  1. error message appears when function is called
    By babygal in forum Qt Programming
    Replies: 11
    Last Post: 15th June 2010, 00:49
  2. webkit and keycode - F1...F12.
    By kwisp in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2009, 21:18
  3. QAxWidget
    By rajeshs in forum Qt Programming
    Replies: 1
    Last Post: 5th September 2008, 06:13
  4. QSystemTrayIcon: Overridden balloon msg
    By further in forum Qt Programming
    Replies: 2
    Last Post: 17th April 2008, 11:58
  5. QAxWidget
    By chak_med in forum Newbie
    Replies: 1
    Last Post: 10th September 2006, 21:05

Tags for this Thread

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.