I\'ve just been working through some simple programs using SDL and it made me think back to some Java GUIs I\'ve written.
In the simple SDL programs, I have a loop that
"...does Java just handle this polling loop in the background for us...?"
Pretty much, yes. The UI system provides the program with access to a queue that contains events that have occurred and the target. The program runs through a loop requesting items from this queue and then does whatever. Libraries like Qt and Java call special functions within the widget classes that tell them an event has happened so that the system can function from there, however stipulated by the API. The library has to translate from the system specific window ID to the class governing that widget in order to do so.
Qt provides access to this function in the form of protected, virtual onXxxxEvent() functions. The standard behavior of many widgets is to generate signals in response to events, but these are always some translated form of the event specific to the particular widget. Qt provides you access to this so that you can override the way a widget handles an event or to add additional behavior for events it never listened to before (through subclassing).
Each UI system is slightly different but they are all basically the same in this manner in my experience. We're talking raw win32 and Xlib here.