Results 1 to 6 of 6

Thread: Add virtual keyboard to window using QWidget's "Promote to" feature?

  1. #1
    Join Date
    Oct 2015
    Posts
    28
    Thanks
    10
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Add virtual keyboard to window using QWidget's "Promote to" feature?

    Hi,

    I'm interested in adding a virtual keyboard to my application. I found this virtual keyboard that I want to use but I need to open it inside my application instead of opening it in a separate window. To do this I've added the header + source file to my project, added an empty widget to my UI and promoted it to the keyboard class. This gives me the following errors:

    /home/stud/devel/build-keyboardTest-Desktop-Debug/ui_keyboardtest.h:30: error: 'keyboard' does not name a type
    keyboard *widget;
    ^
    /home/stud/devel/build-keyboardTest-Desktop-Debug/ui_keyboardtest.h:42: error: 'widget' was not declared in this scope
    widget = new keyboard(centralWidget);
    ^
    /home/stud/devel/build-keyboardTest-Desktop-Debug/ui_keyboardtest.h:42: error: expected type-specifier before 'keyboard'
    widget = new keyboard(centralWidget);
    ^
    I'm able to open the keyboard in a separate window, but this doesn't work. Also promote widget calls the constructor that takes only QWidget*, so the "Promote to" feature might not be an option for my classes that take more than QWidget* in the constructor. How can I do this in that case?

    The virtual keyboard is found here:
    https://www.kdab.com/qt-input-method-virtual-keyboard/

    Source code:
    https://github.com/KDAB/virtual-keyb.../master/server

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Add virtual keyboard to window using QWidget's "Promote to" feature?

    Quote Originally Posted by Leutzig View Post
    /home/stud/devel/build-keyboardTest-Desktop-Debug/ui_keyboardtest.h:30: error: 'keyboard' does not name a type
    keyboard *widget;
    ^
    Look at line 6 in keyboard.h. All three errors will vanish once you fix this one.

    Quote Originally Posted by Leutzig View Post
    Also promote widget calls the constructor that takes only QWidget*, so the "Promote to" feature might not be an option for my classes that take more than QWidget* in the constructor. How can I do this in that case?
    You can't. That is the limit of promotion: by sticking to the basic QWidget interface, you cannot expect Designer to do anything that a QWidget cannot do. I strongly recommend that every widget class have at least a (QWidget *) constructor that does the default setup, and methods to alter this setup after construction.

  3. #3
    Join Date
    Oct 2015
    Posts
    28
    Thanks
    10
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Add virtual keyboard to window using QWidget's "Promote to" feature?

    Thanks, I realized that keyboard should be written with a capital "K" everywhere, and the errors were gone. Now I'm a bit confused as to why my virtual keyboard opens in a separate window when I'm using promotion. In keyboard's constructor I set the visibility to true and if I resize the empty widget, the size of the virtual keyboard changes (opened separately).

    Skærmbillede 2016-04-30 kl. 01.22.23.jpg

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,155
    Thanks
    295
    Thanked 854 Times in 841 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Add virtual keyboard to window using QWidget's "Promote to" feature?

    Have you added this new Keyboard instance to a layout inside your "central widget" (whatever that is)? Is "central widget" non-NULL?

  5. #5
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Add virtual keyboard to window using QWidget's "Promote to" feature?

    The keyboard is a separate window because it is configured as a tool window. Its constructor calls QWidget::setWindowFlags() and passes the Qt::Tool flag. You should try removing this line entirely.

  6. #6
    Join Date
    Oct 2015
    Posts
    28
    Thanks
    10
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Add virtual keyboard to window using QWidget's "Promote to" feature?

    Yea that was it. Looks good now. Thanks a lot for the help.

    // Leutzig
    Last edited by Leutzig; 1st May 2016 at 00:59.

Similar Threads

  1. Replies: 6
    Last Post: 2nd November 2015, 00:40
  2. Replies: 3
    Last Post: 2nd October 2012, 11:16
  3. "Render" Qt dialog window from ".ui" file
    By BitEater in forum Qt Programming
    Replies: 1
    Last Post: 8th July 2011, 15:40
  4. Add "Check for updates" feature
    By jiveaxe in forum Qt Programming
    Replies: 20
    Last Post: 19th September 2008, 17:39
  5. Using the "pixmap function" feature
    By Michiel in forum Qt Tools
    Replies: 8
    Last Post: 24th May 2007, 15:55

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.