PDA

View Full Version : Q Virtual Keyboard (XTestFakeKeyEvent) running within other Qt App. Focus problem?



taraj
18th August 2011, 08:01
Hello,

I have been using the following keyboard as a standalone application

http://qt-apps.org/content/show.php/QVKeyboard?content=77983

and it works great.

I wish to integrate this application into an exisiting product. I have a toolbar (QWidget) with buttons and edit boxes, i also have a display (QWidget), both are separate classes that are stared up in main() with 'new'. On the toolbar I have a QToolButton that when i press i wish to activate the qvkeyboard, when i press again i wish to close the qvkeyboard. I have attempted to do this 2 ways, both have problems though.

1.Use QProcess which calls proc->start("./qvkeyboard"). This works and qvkeyboard is able to be used/interacts with QLineEdit etc on the toolbar that the QToolbutton is on. Problem I have is that when i press the QToolButton again to close the qvkeyboard it won't. I have tried proc->kill and proc->terminate and it does nothing. Is there a way to send a signal/slot to a proc, or a message somehow?

2. I have intergrated the qvkeyboard code into my existing produce (called it KeyPadwindow). I create it with

KeyPadwindow = new Q_KeyPadwindow(0, Qt::FramelessWindowHint|Qt::WindowStaysOnTop)
at system start up then use

KeyPadWindow->show()
When the QToolButton is pressed
This show command opens the KeyPadwindow but it will not interact with the QLineEdit boxes in the toolbar. Do i need to get focus? Does the XTestFakeKeyEvent only send fake key to application outside the one that the code is being run?

I think that instead of using XTestFakeKeyEvent that i could use signals/slots but i would need to create a QKeyEvent for all the keys on the keyboard and this seems a messy way. Also how do i determine where the focus is between my 2 widgets (toolbar and display)? I need to be able to send key presses to both depending on where the focus is.
Depending on the key pressed can the focus be changed between the two? I don't really understand QFocus...


Hope that makes sense and some kind person can help

cheers,
X_Key_confused....

high_flyer
19th August 2011, 10:01
I have tried proc->kill and proc->terminate and it does nothing.

I have intergrated the qvkeyboard code into my existing produce
I don't understand: do you use the virtual keyboard as a QProcess or do you use it inside your code?

taraj
22nd August 2011, 03:31
I have tried it both ways, as a QProcess and as integrated inside the code (not at the same time)

proc->kill now works, not sure why it didn't before, but i would much prefer to integrate it into the code rather than a QProcess but it doesn't seem to get the focus for the widgets correct when inside the code?

Thanks

high_flyer
22nd August 2011, 09:47
but it doesn't seem to get the focus for the widgets correct when inside the code?
You didn't provide any details to the code so its hard to say...