simplified from Qt, see note
1