PDA

View Full Version : focousinevent not working in QLineEdit



vjsharma_30
18th February 2010, 21:16
I have overriddent he focusInevent in my calss .But i am not able to receive any event in my class

This is my class

class exportData : public QWidget {
Q_OBJECT
public:
exportData(QWidget *parent = 0);
~exportData();

protected:
void changeEvent(QEvent *e);
virtual void focusInEvent( QFocusEvent * e );
}

and i implemented the focusInEvent as below


void exportData::focusInEvent(QFocusEvent *e)
{

if(e->type() == QFocusEvent::FocusIn)
{
keyBoard->show();
ui->edtFileName->setFocus();
}
else if(e->type() == QFocusEvent::FocusOut)
{
keyBoard->hide();
}

}

I have a line edit widget in the main form. What i want to do is call this focusinEvent whenevr i click on that line edit. I don't want to use the keyboard as the application will have to reside on a touch panel system.I wonder why focusInEvent is not being called?

navi1084
19th February 2010, 04:13
Then set the focus policy either Qt::ClickFocus or Qt::StrongFocus using setFocusPolicy();

If this also doesn't work use eventHandler() .