I desire to make a smart-edit feature to a program, so that it's possible to edit a numeric value on a QlineEdit by pressing up- or down-arrow-key.
See attachment to get the idea:
IBeam.png
What I have so far:
- QLineEdit in a mainwindow
- An eventFilter which detects when I press the up-arrow-key on the QLineEdit
QKeyEvent *keyEvent
= static_cast<QKeyEvent
*>
(event
);
if ((event
->type
() == QEvent::KeyPress) && keyEvent
->key
() == 16777235) { qDebug("Pressed the up-arrow-key. Should now increase the digit (of the numeric value) which is in front of the IBeam/cursor (on the numeric value associated with the QLineEdit for this filter event)");
return true;
} else {
// standard event processing
return QObject::eventFilter(obj, event
);
}
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event){
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if ((event->type() == QEvent::KeyPress) && keyEvent->key() == 16777235) {
qDebug("Pressed the up-arrow-key. Should now increase the digit (of the numeric value) which is in front of the IBeam/cursor (on the numeric value associated with the QLineEdit for this filter event)");
return true;
} else {
// standard event processing
return QObject::eventFilter(obj, event);
}
}
To copy to clipboard, switch view to plain text mode
The question: Is there some practical method allowing me to increase or decrease the digit in front of the Ibeam on a keystroke event?
Bookmarks