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. Hwo to discard mousepressevent and mousemoveevent?
Qt 6.11 is out! See what's new in the release blog

Hwo to discard mousepressevent and mousemoveevent?

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

    now . i clike a button to execute a function,but this function's execution efficiency is not high,so my code can break down ,when i clike mouse leftbutton continually in function's execution's process. thanke you

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bodzio131
      wrote on last edited by
      #2

      If your function is time consuming then you will get frozen GUI and nobody can click any button, thus you could not care ;)
      But to be serious you should delegate heavy work into separated thread, or use co-operative execution, and then: 1) you could disconnect the function for processing time, 2) you could set a flag which suppresses new processing, 3) you could use progress/throbber which blocks gui but doesn't freeze it.

      1 Reply Last reply
      0
      • JeroentjehomeJ Offline
        JeroentjehomeJ Offline
        Jeroentjehome
        wrote on last edited by
        #3

        Or at the start of the eventhandler, set a 'disable' button, at the end you will set a 'enable'. Only one event will be handled.

        Greetz, Jeroen

        1 Reply Last reply
        0
        • F Offline
          F Offline
          foxgod
          wrote on last edited by
          #4

          how to control eventLOOP.i use QApplication::processEvent() to do with mousePressEvent(),but when i clike leftbutton that produce mousePressEvent() ,my code will break down.

          how to control eventloop to diacard mouseevent.

          1 Reply Last reply
          0
          • F Offline
            F Offline
            foxgod
            wrote on last edited by
            #5

            [quote author="Bogdan" date="1385544352"]If your function is time consuming then you will get frozen GUI and nobody can click any button, thus you could not care ;)
            But to be serious you should delegate heavy work into separated thread, or use co-operative execution, and then: 1) you could disconnect the function for processing time, 2) you could set a flag which suppresses new processing, 3) you could use progress/throbber which blocks gui but doesn't freeze it.[/quote]

            how to blocks gui?.thank you.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              bodzio131
              wrote on last edited by
              #6

              You need to read more about Qt event loop mechanism and make sure you understand it. Your function is called by Qt gui event loop as a reaction on button click. If your function does heavy (time consuming) processing then it means it blocks event loop. It means it blocks gui refreshing, so it means your gui is frozen during this processing. Because of that I wrote that you need to delegate heave work into separate thread, or just do not block function called by gui event loop (you don't want to have frozen gui, do you?). Of course you can call processEvents periodically during this processing to force events processing, but IMHO it's not good solution and should be avoided.

              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