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. QMouseEvent with delay
Forum Updated to NodeBB v4.3 + New Features

QMouseEvent with delay

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 218 Views 3 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.
  • J Offline
    J Offline
    james b-s
    wrote 23 days ago last edited by james b-s
    #1

    Qt 5.15. Windows.

    I have a QMouseEvent (left button press). I'm trying to add a delay.

    I save the mouse event and assert that the left button is pressed.
    After a delay, just before passing it on to lower level code to be acted upon, I check the saved mouse event, and it still has the same pointer, but the left button is no longer pressed.

    saving the mouse press

    m_pMousePressEvent = pEvent;
    assert((m_pMousePressEvent->button() == Qt::LeftButton));
    

    Testing the event a half second later

    assert(m_pMousePressEvent->button() == Qt::LeftButton);
    

    Even when the button is still pressed.

    Anyone have any idea what is going on?

    According to the debugger, the value is changed here:

    >	CoreUIComponents.dll!Microsoft::CoreUI::Formatting::CnSerialize::InitializeMethod(class Microsoft::CoreUI::MessagingInterop::MessageFactory *,class Microsoft::CoreUI::MessagingInterop::IMessagePort *,enum Microsoft::CoreUI::Formatting::CnSerialize::MessageKind,struct Cn::TypeExtra_Reflection const *,unsigned short,enum Microsoft::CoreUI::Formatting::CnSerialize::InitializeIntent)	Unknown
     	CoreUIComponents.dll!Microsoft::CoreUI::Proxy::MessageProxy::Send()	Unknown
     	CoreUIComponents.dll!Proxy_IRemoteTextInputServer$R::IRemoteTextInputServer_Impl::InputHostFocusLeave(class System::Object *,unsigned int,struct Microsoft::CoreUI::MessagingInterop::RoutingInfo,bool)	Unknown
     	CoreUIComponents.dll!IRemoteTextInputServer::InputHostFocusLeave(unsigned int,struct Microsoft::CoreUI::MessagingInterop::RoutingInfo,bool)	Unknown
     	CoreUIComponents.dll!IRemoteTextInputServer$X__ExportAdapter::InputHostFocusLeave(unsigned int,struct Microsoft::CoreUI::MessagingInterop::RoutingInfo,bool)	Unknown
     	TextInputFramework.dll!TextInputHost::InputHostFocusLeave()	Unknown
     	TextInputFramework.dll!TextInputHost::PutHasFocusInternal()	Unknown
     	msctf.dll!CThreadInputMgr::OnInputFocusEvent(unsigned long,struct HWND__ *,long,long,unsigned long,unsigned long)	Unknown
     	msctf.dll!CThreadInputMgr::OnCiceroEvent()	Unknown
     	msctf.dll!WinEventProc(struct HWINEVENTHOOK__ *,unsigned long,struct HWND__ *,long,long,unsigned long,unsigned long)	Unknown
     	user32.dll!__ClientCallWinEventProc()	Unknown
     	ntdll.dll!KiUserCallbackDispatcherContinue()	Unknown
     	win32u.dll!NtUserPeekMessage()	Unknown
     	user32.dll!_PeekMessage()	Unknown
     	user32.dll!PeekMessageW()	Unknown
     	Qt5Core.dll!QEventDispatcherWin32::processEvents() + 766 bytes	Unknown
     	qwindows.dll!qt_plugin_query_metadata() + 8089 bytes	Unknown
     	Qt5Core.dll!QEventLoop::exec() + 444 bytes	Unknown
     	Qt5Core.dll!QCoreApplication::exec() + 340 bytes	Unknown
    
    
    J 1 Reply Last reply 23 days ago
    0
    • J james b-s
      23 days ago

      Qt 5.15. Windows.

      I have a QMouseEvent (left button press). I'm trying to add a delay.

      I save the mouse event and assert that the left button is pressed.
      After a delay, just before passing it on to lower level code to be acted upon, I check the saved mouse event, and it still has the same pointer, but the left button is no longer pressed.

      saving the mouse press

      m_pMousePressEvent = pEvent;
      assert((m_pMousePressEvent->button() == Qt::LeftButton));
      

      Testing the event a half second later

      assert(m_pMousePressEvent->button() == Qt::LeftButton);
      

      Even when the button is still pressed.

      Anyone have any idea what is going on?

      According to the debugger, the value is changed here:

      >	CoreUIComponents.dll!Microsoft::CoreUI::Formatting::CnSerialize::InitializeMethod(class Microsoft::CoreUI::MessagingInterop::MessageFactory *,class Microsoft::CoreUI::MessagingInterop::IMessagePort *,enum Microsoft::CoreUI::Formatting::CnSerialize::MessageKind,struct Cn::TypeExtra_Reflection const *,unsigned short,enum Microsoft::CoreUI::Formatting::CnSerialize::InitializeIntent)	Unknown
       	CoreUIComponents.dll!Microsoft::CoreUI::Proxy::MessageProxy::Send()	Unknown
       	CoreUIComponents.dll!Proxy_IRemoteTextInputServer$R::IRemoteTextInputServer_Impl::InputHostFocusLeave(class System::Object *,unsigned int,struct Microsoft::CoreUI::MessagingInterop::RoutingInfo,bool)	Unknown
       	CoreUIComponents.dll!IRemoteTextInputServer::InputHostFocusLeave(unsigned int,struct Microsoft::CoreUI::MessagingInterop::RoutingInfo,bool)	Unknown
       	CoreUIComponents.dll!IRemoteTextInputServer$X__ExportAdapter::InputHostFocusLeave(unsigned int,struct Microsoft::CoreUI::MessagingInterop::RoutingInfo,bool)	Unknown
       	TextInputFramework.dll!TextInputHost::InputHostFocusLeave()	Unknown
       	TextInputFramework.dll!TextInputHost::PutHasFocusInternal()	Unknown
       	msctf.dll!CThreadInputMgr::OnInputFocusEvent(unsigned long,struct HWND__ *,long,long,unsigned long,unsigned long)	Unknown
       	msctf.dll!CThreadInputMgr::OnCiceroEvent()	Unknown
       	msctf.dll!WinEventProc(struct HWINEVENTHOOK__ *,unsigned long,struct HWND__ *,long,long,unsigned long,unsigned long)	Unknown
       	user32.dll!__ClientCallWinEventProc()	Unknown
       	ntdll.dll!KiUserCallbackDispatcherContinue()	Unknown
       	win32u.dll!NtUserPeekMessage()	Unknown
       	user32.dll!_PeekMessage()	Unknown
       	user32.dll!PeekMessageW()	Unknown
       	Qt5Core.dll!QEventDispatcherWin32::processEvents() + 766 bytes	Unknown
       	qwindows.dll!qt_plugin_query_metadata() + 8089 bytes	Unknown
       	Qt5Core.dll!QEventLoop::exec() + 444 bytes	Unknown
       	Qt5Core.dll!QCoreApplication::exec() + 340 bytes	Unknown
      
      
      J Offline
      J Offline
      JonB
      wrote 23 days ago last edited by
      #2

      @james-b-s

      After a delay,

      How do you implement this? Do you mean you set off a QTimer and allow the original event to exit, or do you mean you put a blocking loop in and stay in original event?

      but the left button is no longer pressed.

      Even when the button is still pressed.

      Maybe someone else does understand, but I do not know what to make of these two statements.

      You save a QEvent * (pointer) in m_pMousePressEvent. Depending on your answers to proceeding questions, how do you know whether the original event pointed to which you have saved is either still valid or has/has not had its content overwritten?

      1 Reply Last reply
      0
      • J Offline
        J Offline
        james b-s
        wrote 23 days ago last edited by
        #3

        Actually, I suspect that the original mouse event is being deleted and I need to copy the event and not just the pointer.

        J P 2 Replies Last reply 23 days ago
        0
        • J james b-s
          23 days ago

          Actually, I suspect that the original mouse event is being deleted and I need to copy the event and not just the pointer.

          J Offline
          J Offline
          JonB
          wrote 23 days ago last edited by JonB
          #4

          @james-b-s
          That would be my thought! As I said depends whether you stay in original event handler or exit it and it gets called again. I don't think Qt guarantees a QEvent will live longer than the handler it is passed to, else when would it get deleted? If the same memory area happens to get re-used for subsequent events then your retained pointer may actually point to new event information. Copy the event (if it's copyable) or at least the bits inside it you want to know about if you need to access it later on.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jeremy_k
            wrote 22 days ago last edited by
            #5

            The event object documents the state of the system at the time of the event generation, not at the time of examination. Saving it to examine later won't tell the application anything about the system at that later point.

            Have you seen QGuiApplication::mouseButtons()?

            Asking a question about code? http://eel.is/iso-c++/testcase/

            1 Reply Last reply
            0
            • J james b-s
              23 days ago

              Actually, I suspect that the original mouse event is being deleted and I need to copy the event and not just the pointer.

              P Offline
              P Offline
              Pl45m4
              wrote 22 days ago last edited by
              #6

              @james-b-s

              Just curious:
              Where do you click and what do you want to do with that information/delay?
              Maybe there's a better way to achieve this


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              1 Reply Last reply
              0

              1/6

              22 May 2025, 13:47

              • Login

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