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. Why QT doesn't see all clicks?
Qt 6.11 is out! See what's new in the release blog

Why QT doesn't see all clicks?

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

    Hello,

    I have a QWidget ( myClass ) and when I click on it I would like to exec qDialog. Everything works, but when I click two times in a row fast, I go only once to mousePressEvent. My code:

    void myClass::mousePressEvent(QMouseEvent *event)    // I click on this widget
    {
            qInfo()<<"CLICK!";
    
            QPoint global = mapToGlobal( QPoint(0,0) );                                                      // this and next line only set position
           
            dialog->setGeometry( global.x(), global.y()+height(), 500, 500 );
           
            dialog->exec();
    }
    

    When I click fast two Times I get:
    "CLICK!"

    When I click two times in a normal speed ( 1 per second ) I get:
    "CLICK!"
    "CLICK!"

    When I delete line:

    dialog->exec();
    

    I can clicked very fast and everything works perfect. So exec() is very expensive.

    Is there a way to use exec() and can clicked fast and get all "CLICK!"?

    EDIT:
    When I change exec() to show() result is the same: I don't see all clicks when click fast

    jsulmJ Pablo J. RoginaP 2 Replies Last reply
    0
    • T TomNow99

      Hello,

      I have a QWidget ( myClass ) and when I click on it I would like to exec qDialog. Everything works, but when I click two times in a row fast, I go only once to mousePressEvent. My code:

      void myClass::mousePressEvent(QMouseEvent *event)    // I click on this widget
      {
              qInfo()<<"CLICK!";
      
              QPoint global = mapToGlobal( QPoint(0,0) );                                                      // this and next line only set position
             
              dialog->setGeometry( global.x(), global.y()+height(), 500, 500 );
             
              dialog->exec();
      }
      

      When I click fast two Times I get:
      "CLICK!"

      When I click two times in a normal speed ( 1 per second ) I get:
      "CLICK!"
      "CLICK!"

      When I delete line:

      dialog->exec();
      

      I can clicked very fast and everything works perfect. So exec() is very expensive.

      Is there a way to use exec() and can clicked fast and get all "CLICK!"?

      EDIT:
      When I change exec() to show() result is the same: I don't see all clicks when click fast

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @TomNow99 Because dialog->exec() is a blocking call which blocks the event loop...
      Use show() instead of exec().

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply
      2
      • jsulmJ jsulm

        @TomNow99 Because dialog->exec() is a blocking call which blocks the event loop...
        Use show() instead of exec().

        T Offline
        T Offline
        TomNow99
        wrote on last edited by
        #3

        @jsulm Thank you! But look at my EDIT ( I have to added it when you wrote your post )

        jsulmJ 1 Reply Last reply
        0
        • T TomNow99

          @jsulm Thank you! But look at my EDIT ( I have to added it when you wrote your post )

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #4

          @TomNow99 Then I think the second click does not arrive the widget anymore as the dialog is being shown.
          What happens if you use show() wait until dialog is shown move it away from that widget and then click the widget to times fast?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • T Offline
            T Offline
            TomNow99
            wrote on last edited by
            #5

            @jsulm I can't move dialog because it is Qt::FramelessWindowHint and Qt::Window and Qt::Popup.

            1 Reply Last reply
            0
            • T TomNow99

              Hello,

              I have a QWidget ( myClass ) and when I click on it I would like to exec qDialog. Everything works, but when I click two times in a row fast, I go only once to mousePressEvent. My code:

              void myClass::mousePressEvent(QMouseEvent *event)    // I click on this widget
              {
                      qInfo()<<"CLICK!";
              
                      QPoint global = mapToGlobal( QPoint(0,0) );                                                      // this and next line only set position
                     
                      dialog->setGeometry( global.x(), global.y()+height(), 500, 500 );
                     
                      dialog->exec();
              }
              

              When I click fast two Times I get:
              "CLICK!"

              When I click two times in a normal speed ( 1 per second ) I get:
              "CLICK!"
              "CLICK!"

              When I delete line:

              dialog->exec();
              

              I can clicked very fast and everything works perfect. So exec() is very expensive.

              Is there a way to use exec() and can clicked fast and get all "CLICK!"?

              EDIT:
              When I change exec() to show() result is the same: I don't see all clicks when click fast

              Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

              @TomNow99 said in Why QT doesn't see all clicks?:

              but when I click two times in a row fast,

              Have you tried using mouseDoubleClickEvent() event handler?

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              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