Results 1 to 18 of 18

Thread: virtual keyboard done with qt4-designer

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2010
    Location
    Bangalore
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default Re: virtual keyboard done with qt4-designer

    Qt Code:
    1. bool TME_COM::eventFilter(QObject* call_object, QEvent* pevent)
    2. {
    3. QLineEdit *isQLineEdit = static_cast<QLineEdit*>(call_object);
    4.  
    5. if(call_object != ui->TME_COM_ETHER1_IP1_TXTED) return false;
    6. qDebug("Entering if\n");
    7. if (pevent->type() == QEvent::FocusIn)
    8. {
    9. qDebug("entering show\n");
    10. virtualkeyboard->show();
    11. return true;
    12. }
    13. else
    14. {
    15. qDebug("entering hide\n");
    16. virtualkeyboard->hide();
    17. return false;
    18. }
    19. }
    To copy to clipboard, switch view to plain text mode 

    Yes, Of-course I've called installEventFilter() for the line edits.
    "Not working" I mean if I click on line edit VKB is not displaying.
    So as you told I put some Debug statements and tried, actually when I open the screen itself it's entering this event filter function. The program is not waiting till I click on lline edit. As soon as I open the TME_COM screen it's entering the event filter function. But I don't want that, whenever I click on line edit it should enter the event filter function.

    In the output It's printing following Debug statements

    Entering if
    Entering hide
    Entering if
    Entering hide

    and I'm getting one warning," unused variable isQlineEdit". What should I do to display the VKB for click on line edit?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard done with qt4-designer

    The program is not waiting till I click on lline edit. As soon as I open the TME_COM screen it's entering the event filter function. But I don't want that, whenever I click on line edit it should enter the event filter function.
    That is a correct behaviour.
    An event filter gets all the events for the filtered widget.
    In the function it self, as you are doing, you should filter out the event you want to handle.
    So that is ok.

    The warning you get tells you what the problem is - you have defined 'isQlineEdit' but you don't use it.
    Just delete that line and the warning will go away.

    Try 'QEvent::EnterEditFocus' instead of 'QEvent::FocusIn'

    Yes, Of-course I've called installEventFilter() for the line edits.
    Well, nothing is 'of course' when you try to debug code you can't see
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Oct 2010
    Location
    Bangalore
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default Re: virtual keyboard done with qt4-designer

    I tried with 'QEvent::EnterEditFocus', with this also VKB is not displaying, actually it's saying "EnterEditfocus is not a member of QEvent ".
    Is there any function other than eventFilter(), so that I can use here. Because, I don't want to show the keyboard as soon as the screen opens. Instead, I want to display the VKB only when clicked on line edit.


  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard done with qt4-designer

    "EnterEditfocus is not a member of QEvent ".
    It should be EnterEditFocus, with a 'F'.

    In such cases check the QEvent documentation.

    s there any function other than eventFilter(), so that I can use here.
    You can subclass QLineEdit and overload focusInEvent().
    But then your QLineEdit will have to get a pointer to the VKB, or otherwise have access to it.

    Don't expect to be fed everything with a spoon - read the docs!
    Look for answers in the docs!
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Oct 2010
    Location
    Bangalore
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default Re: virtual keyboard done with qt4-designer

    Okay, I'll try with that. Thank you.

  6. #6
    Join Date
    Oct 2010
    Location
    Bangalore
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default Re: virtual keyboard done with qt4-designer

    Hi. I got it worked with following, using signals and slots

    Qt Code:
    1. connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(setWidgets(QWidget*, QWidget*)));
    2.  
    3. void TME_COM::setWidgets(QWidget *old, QWidget *newwid)
    4. {
    5. const char* ab;
    6. if(newwid != 0)
    7. {
    8. ab = newwid->metaObject()->className();
    9. if(strcmp(ab,"QLineEdit")==0)
    10. {
    11. virtualKeyBoard->show();
    12. }
    13. }
    14.  
    15. else
    16. {
    17. virtualKeyBoard->hide();
    18. }
    19. }
    To copy to clipboard, switch view to plain text mode 

    Thanks for your replies.
    I've got one more issue.
    The screens in our project resizes when double clicked on title bar. I want to disable this resize option.
    so the questions are,
    1. How to disable the resize of the screens or widget on double click of the title bar?
    2. How to disable the context menu display, when right clciked on title bar?

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard done with qt4-designer

    Hi. I got it worked with following, using signals and slots
    I was not aware the trolls added a signal for that, its hard to keep up with all the new features! (All though I see its a 4.1 feature (but I didn't need it))
    Well, I learned something new too!
    1. How to disable the resize of the screens or widget on double click of the title bar?
    I don't know if Qt has something "ready" to be used for that.
    You might need to catch the resize event for the window and re implement it.
    2. How to disable the context menu display, when right clciked on title bar?
    See WindowFlags.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  8. #8
    Join Date
    Oct 2010
    Location
    Bangalore
    Posts
    14
    Qt products
    Qt4 Qt/Embedded

    Default Re: virtual keyboard done with qt4-designer

    Hi all,
    I have created a simple application with a single combo box and some push buttons. This is to implement multilingual feature of Qt. I want to dynamically update the combo box if any new .qm file is added to the project folder. I'm getting the file name added to the combo box. But once I select the dynamically added item in the combo box the language changes and the corresponding new item disappears. I want it to be added permanently. please help how to do this.
    Thanks in advance.

    here is the code I've used
    Qt Code:
    1. #include "detect.h"
    2. #include "ui_detect.h"
    3. #include "QFileSystemWatcher"
    4. #include "QFileInfo"
    5. #include "QTranslator"
    6. #include "QTextStream"
    7. #include "QString"
    8. #include "QComboBox"
    9.  
    10. QTranslator langTranslator;
    11. QString line1;
    12. detect::detect(QWidget *parent) :
    13. QDialog(parent),
    14. ui(new Ui::detect)
    15. {
    16. ui->setupUi(this);
    17. qApp->installTranslator(&langTranslator);
    18. system("ls ..\ >new.txt");
    19. system("comm -13 old.txt new.txt >difference.txt");
    20. readdifference();
    21.  
    22. }
    23.  
    24. detect::~detect()
    25. {
    26. delete ui;
    27. }
    28.  
    29. void detect::changeEvent(QEvent *e)
    30. {
    31. QDialog::changeEvent(e);
    32. switch (e->type()) {
    33. case QEvent::LanguageChange:
    34. ui->retranslateUi(this);
    35. break;
    36. default:
    37. break;
    38. }
    39. }
    40.  
    41. void detect::on_comboBox_activated(const QString & text)
    42. {
    43. if(text == tr("French"))
    44. {
    45. langTranslator.load("arrowpad_fr","C:/Documents and Settings/20010833/Desktop/testdet" );
    46. }
    47. else if(text == line1)
    48. {
    49. langTranslator.load(line1,"C:/Documents and Settings/20010833/Desktop/testdet" );
    50. }
    51.  
    52. }
    53. void detect::readdifference()
    54. {
    55. QString path="C:/Documents and Settings/20010833/Desktop/testdet";
    56. QFile nfile("difference.txt");
    57.  
    58. if(!nfile.open(QIODevice::ReadOnly ))
    59. return;
    60. QTextStream in(& nfile);
    61. while(!in.atEnd())
    62. {
    63. line1=in.readLine();
    64. if(line1.endsWith("qm"))
    65. {
    66.  
    67. ui->comboBox->addItem(line1,QVariant::Char);
    68. // break;
    69. }
    70. }
    71. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by madhukiranmp; 30th December 2010 at 08:53.

Similar Threads

  1. Virtual Keyboard on Qtopia 4.2.1
    By shapirlex in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 11th April 2007, 15:51
  2. Compiling error
    By vfernandez in forum Newbie
    Replies: 2
    Last Post: 9th March 2007, 21:02
  3. virtual keyboard
    By sar_van81 in forum Qt Programming
    Replies: 5
    Last Post: 22nd December 2006, 13:40
  4. Replies: 13
    Last Post: 15th December 2006, 11:52
  5. Adding slots in Designer
    By jamos in forum Qt Tools
    Replies: 5
    Last Post: 18th May 2006, 23:28

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
  •  
Qt is a trademark of The Qt Company.