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. What is the function to know if the screen is pressed or not
Forum Updated to NodeBB v4.3 + New Features

What is the function to know if the screen is pressed or not

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 3 Posters 794 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.
  • N Offline
    N Offline
    NGV_Maxime
    wrote on last edited by
    #1

    Hi,

    On Android with qt 5.13.1, I would like to know if the touch screen is pressed or not.
    Is there a function that manages this?

    I'm a beginner, can you help me ?

    Thanks

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      If you are using QML, you can use a MouseArea spanning the whole application window, something like:

      ApplicationWindow {
        // Your normal code here...
      
        MouseArea {
          onClicked: {
            // Or use "onPressed"
            console.log("Screen has been pressed!")
            // This will propagate the click further into your app
            mouse.accepted = false
          }
        }
      }
      

      (Z(:^

      ODБOïO 1 Reply Last reply
      2
      • sierdzioS sierdzio

        If you are using QML, you can use a MouseArea spanning the whole application window, something like:

        ApplicationWindow {
          // Your normal code here...
        
          MouseArea {
            onClicked: {
              // Or use "onPressed"
              console.log("Screen has been pressed!")
              // This will propagate the click further into your app
              mouse.accepted = false
            }
          }
        }
        
        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by ODБOï
        #3

        hi @NGV_Maxime ,
        to add to @sierdzio answer, you need to set the size of the mousearea

        @sierdzio said in What is the function to know if the screen is pressed or not:

        MouseArea {
        anchors.fill : parent //<< give a size
        onClicked: {

        sierdzioS 1 Reply Last reply
        0
        • N Offline
          N Offline
          NGV_Maxime
          wrote on last edited by
          #4

          Hi,

          Thank for your answers.

          No, I do not use QML.

          My problem is as follows :
          A pushbutton stay pressed while I no longer press this button.
          To highlight this problem you must follow the following procedure:
          1: Press (hold) with a first finger on the button
          2: With a 2nd finger, press another area of the screen
          3: Removing 1st finger
          4: Removing the 2nd finger

          It's an app for Android.

          The event "released" is not activated in this case, the button remains visually pressed.

          My idea was to check in real time if a finger is pressed on the screen so as to disable the pressed button

          Can you help me ?

          thank you

          Envoyer des commentaires

          Historique

          Enregistré

          Communauté

          sierdzioS 1 Reply Last reply
          0
          • ODБOïO ODБOï

            hi @NGV_Maxime ,
            to add to @sierdzio answer, you need to set the size of the mousearea

            @sierdzio said in What is the function to know if the screen is pressed or not:

            MouseArea {
            anchors.fill : parent //<< give a size
            onClicked: {

            sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            @LeLev said in What is the function to know if the screen is pressed or not:

            hi @NGV_Maxime ,
            to add to @sierdzio answer, you need to set the size of the mousearea

            Oh, right, I've missed that crucial detail :D Thanks for noticing.

            (Z(:^

            1 Reply Last reply
            1
            • N NGV_Maxime

              Hi,

              Thank for your answers.

              No, I do not use QML.

              My problem is as follows :
              A pushbutton stay pressed while I no longer press this button.
              To highlight this problem you must follow the following procedure:
              1: Press (hold) with a first finger on the button
              2: With a 2nd finger, press another area of the screen
              3: Removing 1st finger
              4: Removing the 2nd finger

              It's an app for Android.

              The event "released" is not activated in this case, the button remains visually pressed.

              My idea was to check in real time if a finger is pressed on the screen so as to disable the pressed button

              Can you help me ?

              thank you

              Envoyer des commentaires

              Historique

              Enregistré

              Communauté

              sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              @NGV_Maxime said in What is the function to know if the screen is pressed or not:

              It's an app for Android.
              The event "released" is not activated in this case, the button remains visually pressed.
              My idea was to check in real time if a finger is pressed on the screen so as to disable the pressed button
              Can you help me ?

              OK so QtWidgets, right? Which Qt version are you using? I think there was a similar bug that was fixed quite recently. So if you are using some older version, please check with newest (5.12.4 or 5.13.1).

              You can see all mouse events that come into your app by installing a custom event filter https://doc.qt.io/qt-5/qobject.html#installEventFilter

              (Z(:^

              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