PDA

View Full Version : About qtopia an virtual keyboard



webquinty
20th February 2009, 14:02
Hello,

I have read that qtopia support virtual keyboard. is it true?
I have downloaded qtopia 4.3.5, and later, I configured it :

./configure -embedded x86 -depths 8,16,24,32 -big-endian -no-cups -qt-gif -qt-libjpeg -qt-libpng -qt-zlib -qt-mouse-linuxtp -no-kbd-tty -qt-kbd-qvfb -qt-mouse-tslib -L /home/john/GeodeProject/Qt-embedded/tslib-src/compilado/lib -I /home/john/GeodeProject/Qt-embedded/tslib-src/compilado/include -lts

Theese options: "-no-kbd-tty -qt-kbd-qvfb" I have supposed that it is to disable tty keyboard and enable virtual keyboard , but it does not work.

any advice??

wysota
21st February 2009, 14:52
I'm not an expert on that but from what I know you made a wrong assumption :)

Qtopia (QtExtended) has its own virtual keyboard which can be used regardless of the real keyboard. You can do that probably by calling some method from Qt Extended API (QWSServer::openKeyboard() maybe?). Qt Embedded has support for multiple keyboard drivers compilation of which is enabled or disabled by configure options. It doesn't state which driver will actually be used by Qtopia. You do that using the QWS_KEYBOARD environment variable.

Another thing is that you can create your own (virtual or not) keyboard if the underlying window system doesn't provide one. You do that with the use of QWSServer::sendKeyEvent() which will feed the input system with the key you pass to the method.

webquinty
22nd February 2009, 08:16
Hello, and thank you for your answer.

I am not a expert too, but your idea to use QWSServer::sendKeyEvent() to make my own keyboard is very good. I will try to use it.

By other hand, perhpas you could help me with other problem.
I have a QLine Edit as input data. I would like to use a virtual keyboard to write data in it, but the problem is that QLineEdit has not click signal like QButton to launch keyboard.
is it possible to modify QlineEdit class to add click event or create my own wigdet with this event???

Best regards

wysota
22nd February 2009, 08:42
You can react on focusIn event of the line edit, I think that would be the best option. You can even apply an event filter on the application so that you have a single place to react on all focusIn and focusOut events of all line edits. On the other hand you can use soft keys to open and close the keyboard regardless of the current focus.

webquinty
23rd February 2009, 16:30
Hello wysota,

Finally, I have used this to detect a click event on QlineEdit:

firts, Constructor Class:


lineEdit1->installEventFilter(this);

and later...


bool MyDialog::eventFilter(QObject* call_object, QEvent* pevent)
{
unsigned long contador;
unsigned long contador2;
QString aux_contador;

contador2++;
aux_contador.setNum(contador2);
textLabel3->setText(aux_contador);
if (pevent->MouseButtonPress == QEvent::MouseButtonPress)
{
if (call_object == lineEdit1)
{
contador++;
aux_contador.setNum(contador);
textLabel4->setText(aux_contador);
retunr true;
}
}else
return false;
}

This function works fine, but only enter once, and no more. I do not find what is the problem. Could you help??

Best regards.

wysota
23rd February 2009, 19:30
What is this code supposed to do? I admit I don't see any sense in it :)

I'd do it more or less like this:

qApp->installEventFilter(myKeyboardObject);
//...
bool myKeyboardClass::eventFilter(QObject *o, QEvent *e){
QLineEdit *le = qobject_cast<QLineEdit*>(o);
if(!le) return QtopiaApplication::eventFilter(o, e);
if(e->type()==QEvent::focusIn){
this->show();
}
}

webquinty
2nd March 2009, 08:35
Hello,

we have a bit problem with qobject_cast.


bool MyDialog::eventFilter(QObject* call_object, QEvent* pevent)
{
Touchpad *myTouchpad;

QLineEdit *isQLineEdit = qobject_cast<QLineEdit*>(call_object);

if (pevent->type() == QEvent::MouseButtonPress)
{
}
}


mydialog.cpp: In member function ‘virtual bool MyDialog::eventFilter(QObject*, QEvent*)’:
mydialog.cpp:540: error: ‘qobject_cast’ was not declared in this scope
mydialog.cpp:540: error: expected primary-expression before ‘*’ token
mydialog.cpp:540: error: expected primary-expression before ‘>’ token

But If I use this code...


bool MyDialog::eventFilter(QObject* call_object, QEvent* pevent)
{
Touchpad *myTouchpad;

QLineEdit *isQLineEdit = static_cast<QLineEdit*>(call_object);

if(!isQLineEdit) return false; // Si no se trata de un QLineEdit, no se hace nada

if (pevent->type() == QEvent::MouseButtonPress)
{
myTouchpad = new Touchpad(isQLineEdit,0,TRUE,WStyle_Customize | WStyle_NoBorder);
myTouchpad->txt_dato->setText(isQLineEdit->text());

myTouchpad->show();
return true;

}else
return false;
}

the application works fine. So, the question is, what is the difference between static_cast and qobject_cast??

Best regards.