I have to get an IP address so I have four QLineEdit input box like this:
[ ] . [ ] . [ ] . [ ]
[ ] . [ ] . [ ] . [ ]
To copy to clipboard, switch view to plain text mode
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:
[...]
[...]
private:
bool eventFilter ( QObject * , QEvent * );
[...]
To copy to clipboard, switch view to plain text mode
(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...";
QWidget::keyPressEvent ( myKeyEvent
);
return true;
}
}
return false;
}
[...]
[...]
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;
}
[...]
To copy to clipboard, switch view to plain text mode
where is my mistake?
thanks,
the_bis
Bookmarks