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. Events delivered to disabled buttons
Forum Updated to NodeBB v4.3 + New Features

Events delivered to disabled buttons

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 2.1k 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.
  • P Offline
    P Offline
    PeterFromThere
    wrote on last edited by
    #1

    Hey there,

    I have the following problem. I create a group of QPushButtons. One is enabled and the others are disabled.
    When I click the enabled button a processing starts, which takes a few seconds. After the processing is finished
    I disable the current enabled button and enable the next button in a row.

    If I click now the second (disabled) button before the processing returns, then the click will be delivered to the second button after it is enabled.

    I tried connect() with Qt::AutoConnection and Qt::DirectConnection, but in both cases I saw the same behaviour.

    I was expecting that the click to the second (disabled) will be lost, but it is not.

    Has anybody an idea what I did wrong? Is this is a bug (I'm using a self compiled 4.7.2)

    Best,
    Pft

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dcbasso
      wrote on last edited by
      #2

      Sorry, for me your explanation is a litle confused!

      1 Reply Last reply
      0
      • T Offline
        T Offline
        terenty
        wrote on last edited by
        #3

        Hi! Is the picture like : you press first button -> your app starts processing and your gui freezes, in this frozen state you click on second button and once your gui unfreezes back the second button receives click event ?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MuldeR
          wrote on last edited by
          #4

          If you call a lengthy function from the first button's clicked() signal, the GUI will freeze, because no event dispatching can happen until the slot (from which you called the lengthy calculation) returned. Thus the click on the second button cannot be processed, until the slot returns and event dispatching continues. However at that time you already have enabled the second button! As a quick hack, you could insert a qApp()->processEvents() after your lengthy calculation has been completed and right before you enable the second button. This makes sure that all pending events get processed while the button is still disabled. The "proper" solution, however, is to put your lengthy calculations into a background thread, so event processing can continue (and the GUI doesn't freeze), while your calculation is running. Blocking the GUI with long calculation is never a good idea...

          My OpenSource software at: http://muldersoft.com/

          Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

          Go visit the coop: http://youtu.be/Jay...

          1 Reply Last reply
          0
          • P Offline
            P Offline
            PeterFromThere
            wrote on last edited by
            #5

            Hi,
            sorry for the confusion guys. Meantime I found the reason for this effect. I blocked the event processing to the background by mistake. Once the lengthy action returned the event processing continued and then the event was deliverd. Definitely my fault. Thank you very much for your support.

            Regards,
            PfT.

            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