Thanks both again! Now I think this is a problem like "If I buy vanilla icecream the car won't start".
There is something wrong
if I start scim automatically when KDE starts by putting scim into "$HOME/.kde/Autostart" as suggested by "/etc/profile.d/scim.sh". Even if I add a delay before the scim command the problem still shows up.
Now I have a fairly effective (though very ugly) workaround -- Do not start scim on KDE start up, but start KDE and then launch a GTK application such as Firefox, Pidgin or whatever. Then the GTK application will bring up scim. After that, all GTK and Qt / KDE applications work well.