Results 1 to 3 of 3

Thread: Edit digit at cursor position in a QlineEdit

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2018
    Posts
    2
    Thanks
    1
    Qt products
    Qt5

    Question Edit digit at cursor position in a QlineEdit

    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

    Qt Code:
    1. bool MainWindow::eventFilter(QObject *obj, QEvent *event){
    2. QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
    3. if ((event->type() == QEvent::KeyPress) && keyEvent->key() == 16777235) {
    4. 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)");
    5. return true;
    6. } else {
    7. // standard event processing
    8. return QObject::eventFilter(obj, event);
    9. }
    10. }
    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?
    Last edited by Egeris; 3rd August 2018 at 17:22.

Similar Threads

  1. Control the position of the icon in a QLineEdit
    By PinTxO in forum Qt Programming
    Replies: 0
    Last Post: 7th September 2016, 10:06
  2. New Register
    By mouni in forum Qt Programming
    Replies: 1
    Last Post: 29th April 2015, 09:13
  3. What is register int?
    By kiboi in forum General Programming
    Replies: 2
    Last Post: 6th November 2012, 23:27
  4. set cursor position in qlineedit with an inputmask
    By guitar1 in forum Qt Programming
    Replies: 2
    Last Post: 11th March 2011, 17:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.