PDA

View Full Version : Qt vs Delphi TApplicationEvents



BingoMaster
26th September 2009, 16:42
In Delphi we have a TApplicationEvent component that if an when your application is Idle you can do processing. The best example is:

Let's say you have a button that is Enabled or Disabled based on data entered. If the data is invalid the button is disabled and when data becames valid you enable the button. But this check is only done when the application sends a IdleEvent.

So does Qt have such a event handler?

I thought it might be on the main form but I did not see it, or maybe I just not looking in the right place.

wysota
26th September 2009, 23:03
In Qt we tend to do something like this using signals and slots. The most straightforward way is to create a signal "dataValidChanged(bool)" and connect it to "setEnabled(bool)" slot of the button. Whenever validity of the data changes, you emit the signal and the button gets enabled or disabled properly. No need to do any periodic checks.

As for idle processing, this is usually done by using a timer with a 0 timeout. You can read a bit about it for example here: http://doc.trolltech.com/qq/qq27-responsive-guis.html#solvingaproblemstepbystep