the_bis
5th June 2008, 17:51
I have to get an IP address so I have four QLineEdit input box like this:
[ ] . [ ] . [ ] . [ ]
I can insert the first number in hte first QLineEdit (mylineEditGetAddressIP_A) and I can go to the second by pressing the tab key. My goal is to skip to the next lineedit also when I press the "." key.
This is my not working code:
(dialog object header):
[...]
private:
bool eventFilter ( QObject * , QEvent * );
[...]
(dialog object c++ code):
[...]
mylineEditGetAddressIP_A->installEventFilter(this);
[...]
bool dialogGetAddressObject::eventFilter ( QObject *object , QEvent *event )
{
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if ( keyEvent->key() == Qt::Key_Period )
{
qDebug () << "Event: Qt::Key_Period - Insert Qt::Key_Tab event...";
QKeyEvent * myKeyEvent = new QKeyEvent ( QEvent::KeyPress , Qt::Key_Tab , Qt::NoModifier, 0);
QWidget::keyPressEvent ( myKeyEvent );
return true;
}
}
return false;
}
[...]
where is my mistake?
thanks,
the_bis
[ ] . [ ] . [ ] . [ ]
I can insert the first number in hte first QLineEdit (mylineEditGetAddressIP_A) and I can go to the second by pressing the tab key. My goal is to skip to the next lineedit also when I press the "." key.
This is my not working code:
(dialog object header):
[...]
private:
bool eventFilter ( QObject * , QEvent * );
[...]
(dialog object c++ code):
[...]
mylineEditGetAddressIP_A->installEventFilter(this);
[...]
bool dialogGetAddressObject::eventFilter ( QObject *object , QEvent *event )
{
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if ( keyEvent->key() == Qt::Key_Period )
{
qDebug () << "Event: Qt::Key_Period - Insert Qt::Key_Tab event...";
QKeyEvent * myKeyEvent = new QKeyEvent ( QEvent::KeyPress , Qt::Key_Tab , Qt::NoModifier, 0);
QWidget::keyPressEvent ( myKeyEvent );
return true;
}
}
return false;
}
[...]
where is my mistake?
thanks,
the_bis