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. Pressing the "Enter" key triggers unwanted response from a Button

Pressing the "Enter" key triggers unwanted response from a Button

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.3k 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.
  • A Offline
    A Offline
    Absurd
    wrote on last edited by
    #1

    I have an application with many Buttons, Widgets, Lables, etc...
    I noticed that every time I press the Enter key - regardless of which of the many widgets has focus - it triggers the pressed() signal associated with the "Refresh" Button you see below in the picture:

    c0c9b3e8-2993-4b21-b9a2-59574a76fd98-image.png

    I assume it has something to do with the fact that this Button is, for some reason, surrounded with Bold frame (unlike the "Initialize Logger" Button, for example, as you can see in the pic).

    1. What does it mean when the Refresh Button has Bold frame?
    2. How do I prevent Enter key press to invoke this signal?

    Thanks

    JonBJ 1 Reply Last reply
    0
    • A Absurd

      I have an application with many Buttons, Widgets, Lables, etc...
      I noticed that every time I press the Enter key - regardless of which of the many widgets has focus - it triggers the pressed() signal associated with the "Refresh" Button you see below in the picture:

      c0c9b3e8-2993-4b21-b9a2-59574a76fd98-image.png

      I assume it has something to do with the fact that this Button is, for some reason, surrounded with Bold frame (unlike the "Initialize Logger" Button, for example, as you can see in the pic).

      1. What does it mean when the Refresh Button has Bold frame?
      2. How do I prevent Enter key press to invoke this signal?

      Thanks

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Absurd
      I thought that bold button is the one with focus, though I could be mistaken?

      You don't say anything about what widget this button is on? A QDialog has a default button, https://doc.qt.io/qt-5/qdialog.html#default-button, is that you? If so, clear the button from being default?

      1 Reply Last reply
      2
      • A Offline
        A Offline
        Absurd
        wrote on last edited by
        #3

        See below pic of how roughly widgets are layed out.
        No matter who has focus - for example - it could be some Radio Button on the uppermost QWidget that you see in the pic - the Refresh Button would still have this Bold frame around it - and Enter key will invoke it...

        4d34cbac-c732-46d8-b388-93ec141ca243-image.png

        JonBJ 1 Reply Last reply
        0
        • A Absurd

          See below pic of how roughly widgets are layed out.
          No matter who has focus - for example - it could be some Radio Button on the uppermost QWidget that you see in the pic - the Refresh Button would still have this Bold frame around it - and Enter key will invoke it...

          4d34cbac-c732-46d8-b388-93ec141ca243-image.png

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @Absurd
          And you read where I wrote

          A QDialog has a default button, https://doc.qt.io/qt-5/qdialog.html#default-button, is that you? If so, clear the button from being default?

          and acted on unsetting the default button, right?

          1 Reply Last reply
          1
          • A Offline
            A Offline
            Absurd
            wrote on last edited by
            #5

            I did.
            On that "Refresh" button I invoked setDefault(false) but it didn't help...

            JonBJ 1 Reply Last reply
            0
            • A Absurd

              I did.
              On that "Refresh" button I invoked setDefault(false) but it didn't help...

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @Absurd
              Not sure. To verify or eliminate this from being the issue, why don't you instead make the Initialize Logger button the default, and see if that changes what happens:

              self.btnInitializeLogger.setDefault(true);
              
              1 Reply Last reply
              0
              • artwawA Offline
                artwawA Offline
                artwaw
                wrote on last edited by
                #7

                Hi,
                <enter> key will always trigger default button as this is default shortcut key. Default button is usually with bold shadow on Windows - the focus is marked differently.

                Please check autodefault properties of the buttons - if the buttons are in the button group, check also settings there.

                For more information please re-read.

                Kind Regards,
                Artur

                1 Reply Last reply
                1

                • Login

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