Results 1 to 9 of 9

Thread: Windows 7 tablet--how to get virtual keyboard for text entry?

  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Windows 7 tablet--how to get virtual keyboard for text entry?

    I'm just now deploying my Qt application on a Windows 7 tablet. I expected the virtual keyboard to come up whenever I touched something like an entry box, but nothing happens.

    Is there something easy I can do to get the virtual keyboard (or numeric keypad) to come up, or do I need to do my own widgets for this that are only used for specific platforms (that don't have physical keyboards).

    Thanks,

    Dave Thomas

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Windows 7 tablet--how to get virtual keyboard for text entry?

    You need a working input context plugin. I don't know if Qt provides one for Win7 tablets. If not, either search the net or implement your own.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Windows 7 tablet--how to get virtual keyboard for text entry?

    No clue what a "working input context plugin" is, but I like learning new things. If it's a big deal, I can just do my own widget that comes up when the entry boxes (or equivalent) are clicked.

    Thanks!

    Dave Thomas

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Windows 7 tablet--how to get virtual keyboard for text entry?

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Windows 7 tablet--how to get virtual keyboard for text entry?

    I used this example:

    http://qt-project.org/doc/qt-4.8/tools-inputpanel.html

    Thanks!

    Dave Thomas


    Added after 56 minutes:


    That works (http://qt-project.org/doc/qt-4.8/tools-inputpanel.html) except I can only add digits, not replace or delete them.

    So, I'm trying to add a "clear" or "delete" button. I replaced the "*" button in Qt Designer with one labelled "Clear" and added a dynamic "buttonValue" with value "C". So a signal gets emitted from "MyInputPanel" with a parameter of 'C' when that button is touched

    The slot in MyInputPanelContext receives the signal with the QChar 'C'. KeyPress and KeyRelease events are generated for the other buttons and sent using QApplicaiton::sendEvent. I'm not aware of an event that will always map to something that will clear the contents of a spinbox, for example.

    So, I'm thinking I'd add a dynamic cast of the widget in focus to each of the widget types for which my application will need the clear function. The call the clear() method after the first dynamic cast that succeeds.

    I'm thinking this might not be the "smart way" to do it but I think it will work. Is there a better way?

    Thanks,

    I used this example:

    http://qt-project.org/doc/qt-4.8/tools-inputpanel.html

    Thanks!

    Dave Thomas


    Added after 56 minutes:


    That works (http://qt-project.org/doc/qt-4.8/tools-inputpanel.html) except I can only add digits, not replace or delete them.

    So, I'm trying to add a "clear" or "delete" button. I replaced the "*" button in Qt Designer with one labelled "Clear" and added a dynamic "buttonValue" with value "C". So a signal gets emitted from "MyInputPanel" with a parameter of 'C' when that button is touched

    The slot in MyInputPanelContext receives the signal with the QChar 'C'. KeyPress and KeyRelease events are generated for the other buttons and sent using QApplicaiton::sendEvent. I'm not aware of an event that will always map to something that will clear the contents of a spinbox, for example.

    So, I'm thinking I'd add a dynamic cast of the widget in focus to each of the widget types for which my application will need the clear function. The call the clear() method after the first dynamic cast that succeeds.

    I'm thinking this might not be the "smart way" to do it but I think it will work. Is there a better way?

    Thanks,

    I used this example:

    http://qt-project.org/doc/qt-4.8/tools-inputpanel.html

    Thanks!

    Dave Thomas


    Added after 56 minutes:


    That works (http://qt-project.org/doc/qt-4.8/tools-inputpanel.html) except I can only add digits, not replace or delete them.

    So, I'm trying to add a "clear" or "delete" button. I replaced the "*" button in Qt Designer with one labelled "Clear" and added a dynamic "buttonValue" with value "C". So a signal gets emitted from "MyInputPanel" with a parameter of 'C' when that button is touched

    The slot in MyInputPanelContext receives the signal with the QChar 'C'. KeyPress and KeyRelease events are generated for the other buttons and sent using QApplicaiton::sendEvent. I'm not aware of an event that will always map to something that will clear the contents of a spinbox, for example.

    So, I'm thinking I'd add a dynamic cast of the widget in focus to each of the widget types for which my application will need the clear function. The call the clear() method after the first dynamic cast that succeeds.

    I'm thinking this might not be the "smart way" to do it but I think it will work. Is there a better way?

    Thanks,


    Added after 49 minutes:


    Not elegant, but this works:

    Qt Code:
    1. void MyInputPanelContext::sendCharacter(QChar character)
    2. {
    3. QPointer<QWidget> w = focusWidget();
    4.  
    5. if (!w)
    6. return;
    7.  
    8. if (character == 'C')
    9. {
    10.  
    11. QKeyEvent delPress(QEvent::KeyPress, Qt::Key_Delete,Qt::NoModifier, QString(character));
    12. QKeyEvent delRelease(QEvent::KeyRelease, Qt::Key_Delete,Qt::NoModifier, QString());
    13.  
    14.  
    15. QApplication::sendEvent(w, &delPress);
    16. QApplication::sendEvent(w, &delRelease);
    17. return;
    18. }
    19.  
    20. QKeyEvent keyPress(QEvent::KeyPress, character.unicode(), Qt::NoModifier, QString(character));
    21. QApplication::sendEvent(w, &keyPress);
    22.  
    23. if (!w)
    24. return;
    25.  
    26. QKeyEvent keyRelease(QEvent::KeyPress, character.unicode(), Qt::NoModifier, QString());
    27. QApplication::sendEvent(w, &keyRelease);
    28. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by davethomaspilot; 8th March 2013 at 15:08.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Windows 7 tablet--how to get virtual keyboard for text entry?

    Basing your solutions on tutorials or examples that have simple usecases in mind often yields bad results -- like in this case.

    Why are you trying to "extend" sendCharacter() when in your case it is not true that every keypress yields a new QChar element that should be added to the input? A trivial solution is to connect the "delete" key to a separate slot (or whatever else piece of code you have) that will generate a proper event and send it to the focus widget.

    Qt Code:
    1. connect(myDeleteButton, SIGNAL(clicked()), myContext, SLOT(sendDelete()));
    2.  
    3. // ...
    4.  
    5. void MyInputPanelContext::sendDelete() {
    6. if(!focusWidget()) return;
    7. QKeyEvent delPress(QEvent::KeyPress, Qt::Key_Delete, Qt::NoModifier);
    8. QApplication::sendEvent(focusWidget(), &delPress);
    9. QKeyEvent delRelease(QEvent::KeyRelease, Qt::Key_Delete, Qt::NoModifier);
    10. QApplication::sendEvent(focusWidget(), &delRelease);
    11. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Windows 7 tablet--how to get virtual keyboard for text entry?

    Yes, I like that better.

    Thanks!

    Dave Thomas


    Added after 52 minutes:


    Except it doesn't work. focusWidget() is returning zero in the sendDelete() method. Yet, it correctly returns a pointer to the spinBox widget when any other button is pushed in the sample code's "sendchCharacter" . I do have the focusPolicy for the delete button set to "NoFocus".

    That doesn't make sense. From the Qt docs:

    QWidget * QApplication::focusWidget () [static]
    Returns the application widget that has the keyboard input focus, or 0 if no widget in this application has the focus.


    Why would the keyboard focus be changing?
    Last edited by davethomaspilot; 8th March 2013 at 23:24.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Windows 7 tablet--how to get virtual keyboard for text entry?

    Maybe you forgot to set your button's focus policy in the input panel to NoFocus and it steals focus from whatever had focus before or something like that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Jun 2012
    Posts
    219
    Thanks
    28
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Windows 7 tablet--how to get virtual keyboard for text entry?

    No, I did have the focusPolicy to NoFocus for the new button.

    I had the send_delete a member function of MyInputPanel when the focusWidget() call was returning null. When I instead made it a member function of MyInputPanelContext (which required making the keypad ui form a public member of MyInput so I could do the connection int the MyInputPanelContext constructor), it works fine.

    Don't understand that at all--but not sure I care now that it's working.

Similar Threads

  1. Disable keyboard input for spinbox entry
    By babygal in forum Qt Programming
    Replies: 8
    Last Post: 2nd December 2016, 01:06
  2. Show virtual keyboard in Windows 8
    By jh in forum Qt Programming
    Replies: 2
    Last Post: 4th February 2013, 23:10
  3. How to get the virtual keyboard?
    By ramesh.bs in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 2nd June 2010, 11:58
  4. Virtual Keyboard?
    By augusbas in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 14th July 2009, 08:55
  5. virtual keyboard
    By sar_van81 in forum Qt Programming
    Replies: 5
    Last Post: 22nd December 2006, 13:40

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.