Results 1 to 20 of 36

Thread: virtual keyboard in QT Application

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    It's a while ago that I made InputDeviceV3.zip, but didn't have a need to build a new one up until now,
    now I needed a virtual input for Qt5.3 so I made the InputDevice working again.
    I didn't do any major changes (only the name), it still only works for QLineEdits
    Here is the download:
    VirtualInput.zip

    How to use:
    • Build the library
    • copy the library to platforminputcontexts in your application or to plugins/platforminputcontexts in your QtDir
    • Add a custom property named "keyboard" (without the quotes) of the type bool to the QLineEdit and set it to enabled
    • For text you can set the maxLength property
    • For values you can add a QIntValidator to the QLineEdit

  2. #2
    Join Date
    Mar 2015
    Posts
    2
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Default Re: virtual keyboard in QT Application

    Hi, thanks for the update.
    I'm pretty new to Qt (and to C++) and I'm having trouble using your project. Running Qt-Creator 3.3.0 and Qt5.4.
    I can open your project, but compiling it yields errors.
    numpad.cpp:166:18: error: taking the address of a temporary object of type 'QVariant' [-Waddress-of-temporary]
    emit dataSet(&QVariant(ui->edValue->text()));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    numpad.cpp:189:33: error: non-const lvalue reference to type 'QString' cannot bind to a temporary of type 'QString'
    if (validator->validate(ui->edValue->text(),pos) == QValidator::Acceptable)
    ^~~~~~~~~~~~~~~~~~~
    /Users/srm/Development/Qt/5.4/clang_64/lib/QtGui.framework/Headers/qvalidator.h:67:37: note: passing argument to parameter here
    virtual State validate(QString &, int &) const = 0;
    ^
    This was running qmake && make in the project dir.
    What am I doing wrong? Do you need any more information?

    EDIT: running on OSX 10.10.2

  3. #3
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    I made the project on a windows machine and a visual studio compiler. It looks like the compiler you are using won't allow temp variables in function calls
    I don't have a mac to try it on.
    Mabe you can find more when googling the error description (QString' cannot bind to a temporary of type 'QString) or start a thread in the newbe section of the forum.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    Instead of taking the address of a temporary QVariant, make it a local variable and take its address.

    In the second error, you are required to pass a reference to a QString. You are trying to pass the return value of a function, which is also a temporary.
    Again, make a local variable, initialiize it with the result of the function and then pass the variable to the validate method.

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    srm (24th March 2015)

  6. #5
    Join Date
    Mar 2015
    Posts
    2
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Default Re: virtual keyboard in QT Application

    Thanks for the pointers. I was able to fix the error messages as per your suggestion.
    For example
    emit dataSet(&QVariant(ui->edValue->text()));
    became
    QVariant qv = QVariant(ui->edValue->text());
    emit dataSet(&qv);
    But now I'm stuck on how to actually use it. I have absolutely no clue on how to incorporate that into my own app. I did a make install but neither do I know how to activate it, nor how to ensure cross platform functionality.

    So I moved over to give http://qt-apps.org/content/show.php/...content=107388 a try, which was mentioned in earlier in this thread.

    Would be great if you could explain/give a sample app on how to actually use such an extra inputcontext, for the total noobs

  7. #6
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    There is a howto on the first page of this thread

  8. #7
    Join Date
    Nov 2015
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: virtual keyboard in QT Application

    hi,thanks for the virtual keyboard
    Last edited by kiran prabhu; 25th November 2015 at 08:18.

  9. #8
    Join Date
    Mar 2016
    Posts
    6
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: virtual keyboard in QT Application

    This looks very useful. I've been trying out the latest VIInputContext class. Any chance you can add some clarification on usage with a mainwindow widget?
    I put this in my mainwindow.h
    VIInputContext inputdevice;
    and in the constructor I do this
    ui->lineEdit->setProperty("keyboard",true);


    But, I must be missing something as when I click in the lineEdit box nothing happens.

  10. #9
    Join Date
    May 2015
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    Quote Originally Posted by srm View Post
    Hi, thanks for the update.
    I'm pretty new to Qt (and to C++) and I'm having trouble using your project. Running Qt-Creator 3.3.0 and Qt5.4.
    I can open your project, but compiling it yields errors.

    This was running qmake && make in the project dir.
    What am I doing wrong? Do you need any more information?

    EDIT: running on OSX 10.10.2
    Looks like signatures changed here and there in Qt 5.4,
    your problem can get around easily as
    QString editedText = ui->edValue->text();
    if (validator->validate(editedText, pos) == QValidator::Acceptable)

    I also changes dataSet(QVariant*) to plain value call dataSet(QVariant)

    but my problem is that I never got the virtual keyboard working on Linux/X11/Qt 5.4.1

    I compiled the library, did sudo make install so it got copied into the right plugin directory
    I set the proper spellword "keyboard" property, hell, I even removed all property checks in the plugin to be sure this is not the problem.

    But on my test application the virtual keyboard never appeared.
    Actually I wonder how "magically" it could appear - currently I am missing some plugin activation on QLineEdit.

    I attach my test project if anyone could see what is the reason of virtual keyboard not showing up...
    Many thanks in advance

    Jan Struhar
    Attached Files Attached Files

  11. #10
    Join Date
    Jun 2015
    Location
    Germany
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    Hi @ all.

    I've tried to use the keyboard in Qt 4. I included the InputDevice.h in my main file and created an intance of the InputDevice like you've posted it.
    But every time I want to build by project it says "undefined reference to 'InputDevice::InputDevice()'".

    Have I need to link something else or include on another place?

    Thanks in advance.

  12. #11
    Join Date
    Jul 2015
    Posts
    8
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    Hi all
    I hava the same problem
    I cant compile my test app, it is fail in <include "inputdevice.h">
    Does anyone actually succeeded to run it ??

  13. #12
    Join Date
    Jul 2015
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Android

    Default Re: virtual keyboard in QT Application

    I am using this in on an embedded arm and the compiler is telling me they cannot find <QtDesigner/QDesignerExportWidget>.

    Any way either not to use this or where I can find this file?

    Thanks

  14. #13
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    kovis did you try to add the plugin to your application build directory?
    what to do:
    * create a folder named platforminputcontexts in next to your executable
    * place the plugin in this directory
    * start the application

    Also important is that the plugin is build in the sameway as your application (debug/release)
    Last edited by StrikeByte; 29th October 2015 at 12:35.

  15. #14
    Join Date
    Feb 2017
    Posts
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: virtual keyboard in QT Application

    Hi StrikeByte,

    I really appreciate the work you've done with the virtual keyboard, but I notice you haven't added a license to the code. I hope this can be placed in the public doman (so anyone can use it for anything, even relicensing) or LGPL, so it can be used in projects using a LGPL licensed Qt.

    Thanks,

    Henrik

  16. #15
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    Hey HenrikSkott,

    You can do with it whatever you want.

    I havn't used this keyboard for a while, but it seems Qt has changed something in the platforminputcontext loader

    if you want to use it you need to add this to your main
    qputenv("QT_IM_MODULE", QByteArray("virtualinput"));

  17. #16
    Join Date
    Aug 2018
    Posts
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    I just created a project on github based on StrikeByte's code. https://github.com/mazj/VirtualInput

Similar Threads

  1. virtual keyboard application : errror during cross-compile
    By sanjeet in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 31st August 2011, 08:48
  2. 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
  3. Virtual Keyboard?
    By augusbas in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 14th July 2009, 08:55
  4. Virtual Keyboard
    By Micawber in forum Qt Programming
    Replies: 1
    Last Post: 3rd September 2007, 19:59
  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.