Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. IP Editor popuppad Delete not clearing LineEdit
QtWS25 Last Chance

IP Editor popuppad Delete not clearing LineEdit

Scheduled Pinned Locked Moved Solved General and Desktop
ip editorplugindeletekeypresseventbackspace
13 Posts 3 Posters 4.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sh1gs
    wrote on 15 Jun 2017, 15:33 last edited by
    #4

    I have seen these two Bug reports and am wondering if that is why I'm having difficult. Could someone shed some light on this?

    QTBUG-19060

    QTBUG-20444

    Thanks.

    K 1 Reply Last reply 15 Jun 2017, 15:46
    0
    • S Sh1gs
      15 Jun 2017, 15:33

      I have seen these two Bug reports and am wondering if that is why I'm having difficult. Could someone shed some light on this?

      QTBUG-19060

      QTBUG-20444

      Thanks.

      K Offline
      K Offline
      koahnig
      wrote on 15 Jun 2017, 15:46 last edited by koahnig
      #5

      @Sh1gs said in IP Editor popuppad Delete not clearing LineEdit:

      I have seen these two Bug reports and am wondering if that is why I'm having difficult. Could someone shed some light on this?

      QTBUG-19060

      QTBUG-20444

      Thanks.

      Both bug reports are referring to 4.7.4 and are closed. One is done and the other was a duplicate. All this is 6 years old.
      In case you are still using Qt4 this would be a good information to supply as well. Probably more than 95% of users here are definitely on Qt 5. As noted above crystal ball reading is not a common gift for those people trying to help.

      Certainly there is always a chance that bugs are slipping back. However, chances are typically in the low percentage.

      Vote the answer(s) that helped you to solve your issue(s)

      S 1 Reply Last reply 15 Jun 2017, 18:19
      0
      • K koahnig
        15 Jun 2017, 15:46

        @Sh1gs said in IP Editor popuppad Delete not clearing LineEdit:

        I have seen these two Bug reports and am wondering if that is why I'm having difficult. Could someone shed some light on this?

        QTBUG-19060

        QTBUG-20444

        Thanks.

        Both bug reports are referring to 4.7.4 and are closed. One is done and the other was a duplicate. All this is 6 years old.
        In case you are still using Qt4 this would be a good information to supply as well. Probably more than 95% of users here are definitely on Qt 5. As noted above crystal ball reading is not a common gift for those people trying to help.

        Certainly there is always a chance that bugs are slipping back. However, chances are typically in the low percentage.

        S Offline
        S Offline
        Sh1gs
        wrote on 15 Jun 2017, 18:19 last edited by
        #6

        @koahnig

        The snide comment is unnecessary. This is why people get frustrated when posting on forums. As I've stated above, I provided as much code as I can, unfortunately I cannot provide everything because of the nature of my job and the hoops I have to jump through to post what I have already.

        I simply came on here to ask for help regarding a KeyPressEvent for a delete key to act as the Backspace key on the keyboard, and why it only deletes the the current LineEdit, moves to the previous LineEdit, and stops.

        M 1 Reply Last reply 15 Jun 2017, 19:36
        0
        • S Sh1gs
          15 Jun 2017, 18:19

          @koahnig

          The snide comment is unnecessary. This is why people get frustrated when posting on forums. As I've stated above, I provided as much code as I can, unfortunately I cannot provide everything because of the nature of my job and the hoops I have to jump through to post what I have already.

          I simply came on here to ask for help regarding a KeyPressEvent for a delete key to act as the Backspace key on the keyboard, and why it only deletes the the current LineEdit, moves to the previous LineEdit, and stops.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 15 Jun 2017, 19:36 last edited by
          #7

          @Sh1gs
          Hi
          When you say delete key , you refer to Qt::Key_Backspace: ?

          So as i understand it, this goes to prev edit if its empty
          case Qt::Key_Backspace:
          if(input->text.isEmpty)
          movPrevLE(i);
          break;

          So i wonder why it can one back and then stop. Did you try with debugger and
          see if movPrevLE(i); does as expected? and than i is also expected index.

          Since it works for first two, i wonder if it seems it as not empty.

          You can insert qDebug statements to see what differs when in second edit and
          if the delete key is still being sent.

          S 1 Reply Last reply 15 Jun 2017, 19:50
          0
          • M mrjj
            15 Jun 2017, 19:36

            @Sh1gs
            Hi
            When you say delete key , you refer to Qt::Key_Backspace: ?

            So as i understand it, this goes to prev edit if its empty
            case Qt::Key_Backspace:
            if(input->text.isEmpty)
            movPrevLE(i);
            break;

            So i wonder why it can one back and then stop. Did you try with debugger and
            see if movPrevLE(i); does as expected? and than i is also expected index.

            Since it works for first two, i wonder if it seems it as not empty.

            You can insert qDebug statements to see what differs when in second edit and
            if the delete key is still being sent.

            S Offline
            S Offline
            Sh1gs
            wrote on 15 Jun 2017, 19:50 last edited by
            #8

            @mrjj

            I apologize for not being more clear. I have a numberpad that pops up on screen whenever one of the LineEdits has focus, essentially my version of a "virtual keyboard". I have made sure that all of the PushButtons don't have focus. I have a "Delete" PushButton within that numberpad, that I want to act as the "Backspace" key on the keyboard. So when "Delete" is clicked, I have:

            QKeyevent *event = new QKeyEvent(QEvent::keyPress, Qt::Key_Backspace, Qt::NoModifier, text, true);
            QApplication::sendEvent(this, event);
            QApplication::postEvent(curEdit, event);
            QKeyevent *rE = new QKeyEvent(QEvent::keyRelease, Qt::Key_Backspace, Qt::NoModifier, text, true);
            QApplication::sendEvent(this, rE);
            QApplication::postEvent(curEdit, rE);
            curEdit->installEventFilter(this);
            

            Then when it goes to the eventFilter, it has as you wrote:

            case Qt::Key_Backspace:
            if(input->text.isempty())
            movPrevLE(i);
            break;
            

            It works with the backspace key on the keyboard, but for the life of me, I cannot figure out why the Delete PushButton I created doesn't act the same way. The Delete button moves fine and deletes if I keep pressing it. But if I press and hold, it only deletes the current LineEdit it is in, moves to the previous LineEdit, and then doesn't delete until it's pressed again.

            I have added qDebug() statements to see if the Press and Release events are occuring, and they are. I have also seen that it is indeed moving to the previous LineEdit.

            M 1 Reply Last reply 15 Jun 2017, 20:10
            0
            • S Sh1gs
              15 Jun 2017, 19:50

              @mrjj

              I apologize for not being more clear. I have a numberpad that pops up on screen whenever one of the LineEdits has focus, essentially my version of a "virtual keyboard". I have made sure that all of the PushButtons don't have focus. I have a "Delete" PushButton within that numberpad, that I want to act as the "Backspace" key on the keyboard. So when "Delete" is clicked, I have:

              QKeyevent *event = new QKeyEvent(QEvent::keyPress, Qt::Key_Backspace, Qt::NoModifier, text, true);
              QApplication::sendEvent(this, event);
              QApplication::postEvent(curEdit, event);
              QKeyevent *rE = new QKeyEvent(QEvent::keyRelease, Qt::Key_Backspace, Qt::NoModifier, text, true);
              QApplication::sendEvent(this, rE);
              QApplication::postEvent(curEdit, rE);
              curEdit->installEventFilter(this);
              

              Then when it goes to the eventFilter, it has as you wrote:

              case Qt::Key_Backspace:
              if(input->text.isempty())
              movPrevLE(i);
              break;
              

              It works with the backspace key on the keyboard, but for the life of me, I cannot figure out why the Delete PushButton I created doesn't act the same way. The Delete button moves fine and deletes if I keep pressing it. But if I press and hold, it only deletes the current LineEdit it is in, moves to the previous LineEdit, and then doesn't delete until it's pressed again.

              I have added qDebug() statements to see if the Press and Release events are occuring, and they are. I have also seen that it is indeed moving to the previous LineEdit.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 15 Jun 2017, 20:10 last edited by
              #9

              @Sh1gs
              Hi
              it might be related to how auto repeat is working.
              I assume you have
              button->setAutoRepeat(true);
              and tweaked setAutoRepeatInterval and setAutoRepeatDelay to your like.

              If you (for test) use a timer and call the same code, does it then work?

              S 2 Replies Last reply 16 Jun 2017, 14:09
              0
              • M mrjj
                15 Jun 2017, 20:10

                @Sh1gs
                Hi
                it might be related to how auto repeat is working.
                I assume you have
                button->setAutoRepeat(true);
                and tweaked setAutoRepeatInterval and setAutoRepeatDelay to your like.

                If you (for test) use a timer and call the same code, does it then work?

                S Offline
                S Offline
                Sh1gs
                wrote on 16 Jun 2017, 14:09 last edited by
                #10

                @mrjj

                Yes, I have delete->setAutoRepeat(true); as well as the parameter AutoRep in my keyPress is set to True. I did not change the autorepeatinterval or delay.

                I am not as familiar with QTimer, so how would I go about implementing that? Would it be something like...

                QTimer *timer = new QTimer(this);
                connect(timer, SIGNAL(timeout()), this, SLOT(what slot to use?));
                timer->start(some amount of time);
                

                Where would this section of code go?

                1 Reply Last reply
                0
                • M mrjj
                  15 Jun 2017, 20:10

                  @Sh1gs
                  Hi
                  it might be related to how auto repeat is working.
                  I assume you have
                  button->setAutoRepeat(true);
                  and tweaked setAutoRepeatInterval and setAutoRepeatDelay to your like.

                  If you (for test) use a timer and call the same code, does it then work?

                  S Offline
                  S Offline
                  Sh1gs
                  wrote on 16 Jun 2017, 15:09 last edited by
                  #11

                  @mrjj

                  Ok, this may not be correct, but I put the following within my eventFilter under Qt::Key_Backspace:

                  QTimer *timer = new QTimer(this);
                  connect(timer, SIGNAL(timeout(), this, SLOT(update()));
                  timer->start(100);
                  

                  Then in my update() slot, I am emitting that "delete" was pressed.

                  Doing this, deletes all of the LineEdit texts. Now I am having an issue that the signal keeps being sent as if the "Delete" key is being pressed/released for eternity, then it crashes. I've tried disconnecting the timer, and I've tried timer->stop() but that doesn't seem to fix the issue either. At least I'm getting closer :)

                  M 1 Reply Last reply 16 Jun 2017, 16:02
                  0
                  • S Sh1gs
                    16 Jun 2017, 15:09

                    @mrjj

                    Ok, this may not be correct, but I put the following within my eventFilter under Qt::Key_Backspace:

                    QTimer *timer = new QTimer(this);
                    connect(timer, SIGNAL(timeout(), this, SLOT(update()));
                    timer->start(100);
                    

                    Then in my update() slot, I am emitting that "delete" was pressed.

                    Doing this, deletes all of the LineEdit texts. Now I am having an issue that the signal keeps being sent as if the "Delete" key is being pressed/released for eternity, then it crashes. I've tried disconnecting the timer, and I've tried timer->stop() but that doesn't seem to fix the issue either. At least I'm getting closer :)

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 16 Jun 2017, 16:02 last edited by
                    #12

                    @Sh1gs
                    Super.
                    It was not meant as a solution.
                    I just wondered if the function would indeed work if something other than a repeating button was used.

                    So it's fair to say the logic works (it will go through all 4) and it will clean all edits
                    and it does send pressed/released as expected.

                    Unless i missed something, it seems its the autorepeat feature that does something unexpected.

                    Also i wonder other thing.

                    in receiveData
                    you call curEdit->installEventFilter(this);
                    and as far as i understand it means it will be called multiple times.
                    Normally you call it once, when you create the curEdit.
                    Not sure if it will only be added once and others calls are just ignored. ( there can be mutiple)
                    Would it be possible to move this line to where you create curEdit so its for sure only installed once?

                    I think i understand the design now and i see no reason to differently with a button but im sure we can find it.

                    S 1 Reply Last reply 16 Jun 2017, 19:25
                    0
                    • M mrjj
                      16 Jun 2017, 16:02

                      @Sh1gs
                      Super.
                      It was not meant as a solution.
                      I just wondered if the function would indeed work if something other than a repeating button was used.

                      So it's fair to say the logic works (it will go through all 4) and it will clean all edits
                      and it does send pressed/released as expected.

                      Unless i missed something, it seems its the autorepeat feature that does something unexpected.

                      Also i wonder other thing.

                      in receiveData
                      you call curEdit->installEventFilter(this);
                      and as far as i understand it means it will be called multiple times.
                      Normally you call it once, when you create the curEdit.
                      Not sure if it will only be added once and others calls are just ignored. ( there can be mutiple)
                      Would it be possible to move this line to where you create curEdit so its for sure only installed once?

                      I think i understand the design now and i see no reason to differently with a button but im sure we can find it.

                      S Offline
                      S Offline
                      Sh1gs
                      wrote on 16 Jun 2017, 19:25 last edited by
                      #13

                      @mrjj

                      I've changed it to check if it's in the first edit, to stop the timer so it'd look like

                      123.___.___.___
                      

                      And then the user will have to manually hit "Delete" repeatedly to delete the characters. This way, the program doesn't crash. It's not exactly elegant, but it's close enough to the requirements I was given.

                      I have also changed that curEdit->installEventFilter(this) is only called once.

                      Thank you very much for your help, I will go ahead and mark this as solved.

                      1 Reply Last reply
                      0

                      13/13

                      16 Jun 2017, 19:25

                      • Login

                      • Login or register to search.
                      13 out of 13
                      • First post
                        13/13
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved