For the bug description and test case see here: https://www.klayout.de/forum/discussion/2047/problem-with-qtreewidgetitem-setbackground#latest The problem boils down to an ownership issue for the Python object.