Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Press Event
Qt 6.11 is out! See what's new in the release blog

Press Event

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 2 Posters 6.0k Views 1 Watching
  • 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
    alfah
    wrote on last edited by
    #1

    hi all,

    I jus want to know if there is a long press event available in Qt :)
    The module im working on currently requires long press. I have seen long press in C7 for uninstalling

    The click event and the press event gives the same result right?

    alfah

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alfah
      wrote on last edited by
      #2

      I found such a funtion,

      can this be manipulated in some way??

      @autoRepeat : bool
      @
      This property holds whether autoRepeat is enabled.
      If autoRepeat is enabled, then the pressed(), released(), and clicked() signals are emitted at regular intervals when the button is down. autoRepeat is off by default. The initial delay and the repetition interval are defined in milliseconds by autoRepeatDelay and autoRepeatInterval.
      Note: If a button is pressed down by a shortcut key, then auto-repeat is enabled and timed by the system and not by this class. The pressed(), released(), and clicked() signals will be emitted like in the normal case.
      Access functions:

      @
      bool autoRepeat () const
      void setAutoRepeat ( bool )
      @

      alfah

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dangelog
        wrote on last edited by
        #3

        Which kind of events are you talking about? Key presses? If so, your system can or can not generate a sequence of key press / key release events, but you can just check with QKeyEvent::isAutoRepeat if the event was generated due to a "true" keypress or is an autorepeat event.

        Software Engineer
        KDAB (UK) Ltd., a KDAB Group company

        1 Reply Last reply
        0
        • A Offline
          A Offline
          alfah
          wrote on last edited by
          #4

          peppe,

          Sorry about not being clear. Yes, Im talking about key presses. I want to know to if there is a way to implement long key press. Ie if i click the button once it does an activity, if i press it twice it does another activity. Now I want to press and hold for some time to start yet another activity.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dangelog
            wrote on last edited by
            #5

            Yes, there is: just keep track of how many times AND how long a key has been pressed span and act accordingly. You just need to override key event handlers, and, as I said, ignore eventual autorepeat events.

            Software Engineer
            KDAB (UK) Ltd., a KDAB Group company

            1 Reply Last reply
            0
            • A Offline
              A Offline
              alfah
              wrote on last edited by
              #6

              i have implemented the first two. But it was not according to the key press event. How can i find out how long the key has been pressed? about overriding, could you jus gimme links of examples or jus elaborate on it?

              Thank you,

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dangelog
                wrote on last edited by
                #7

                [quote author="alfah" date="1313576475"]i have implemented the first two. But it was not according to the key press event. How can i find out how long the key has been pressed?[/quote]

                QElapsedTimer?

                [quote] about overriding, could you jus gimme links of examples or jus elaborate on it?
                [/quote]

                See the QWidget::keyPressEvent / keyReleaseEvent methods, and the related discussion on event handling in Qt.

                Software Engineer
                KDAB (UK) Ltd., a KDAB Group company

                1 Reply Last reply
                0

                • Login

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