Results 1 to 1 of 1

Thread: Problem with keyboard input when using QWinWidget to host Qt widget on CDialog (MFC)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem with keyboard input when using QWinWidget to host Qt widget on CDialog (MFC)

    Hello,

    I'm gradually migrating application from MFC to Qt and using MFCMigrationFramework for this purpose.

    The main problem is in fact that Qt widget which is placed on MFC dialog doesn't handle such keys as Tab, Arrows, Enter, Esc.
    Problem with Tab and arrows was partially solved with this solution:

    I've subclassed QWinWidget and have made next things:
    Constructor:
    Qt Code:
    1. SetWindowLong(winId(), GWL_STYLE, GetWindowLong(winId(), GWL_STYLE) | WS_TABSTOP);
    To copy to clipboard, switch view to plain text mode 
    Overriden winEvent:
    Qt Code:
    1. bool winEvent(MSG *msg, long *result)
    2. {
    3. switch(msg->message)
    4. {
    5. case WM_GETDLGCODE:
    6. *result = DLGC_WANTARROWS | DLGC_WANTTAB;
    7. return true;
    8. }
    9.  
    10. return __super::winEvent(msg, result);
    11. }
    To copy to clipboard, switch view to plain text mode 

    It works except one issue: it's impossible to reach controls on parent dialog (MFC) using Tab key, focus cycles only through child Qt control (the first issue).

    The second issue: Enter and Esc keys are handled only by parent MFC dialog. For instance, it's impossible to close opened popup of combobox (located on Qt widget) by pressing Enter or Esc key - dialog is closed instead (CDialog::OnOK or CDialog::OnCancel is called).

    I've tried this
    Qt Code:
    1. case WM_GETDLGCODE:
    2. *result = DLGC_WANTARROWS | DLGC_WANTTAB | DLGC_WANTALLKEYS;
    To copy to clipboard, switch view to plain text mode 
    but in this case CDialog doesn't handle Esc and Enter keys anymore.

    What is the right solution to handle such situation?
    Last edited by Thart; 5th December 2011 at 18:43.

Similar Threads

  1. How can I set the keyboard input mode?
    By Santiago in forum Newbie
    Replies: 3
    Last Post: 15th November 2011, 13:21
  2. Why modeless dialog block keyboard input
    By franco.amato in forum Qt Programming
    Replies: 1
    Last Post: 15th April 2010, 02:08
  3. [problem] No mouse input to child widget
    By Demandred in forum Newbie
    Replies: 3
    Last Post: 13th April 2010, 13:44
  4. Accessing keyboard input in child process
    By GTBuilder in forum Qt Programming
    Replies: 0
    Last Post: 22nd January 2008, 16:04
  5. How to enable keyboard and mouse as input in qtopia-2.1.1
    By hvreddy1110 in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 12th October 2006, 10:30

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.