You're certainly on the right track.

Line 8 of the first listing declares a variable that goes out of scope at the end of the warmup() method. You almost certainly want the delegate lifetime to be longer than that, i.e. long enough to get back to the event loop. Allocate it on the heap with a suitable QObject parent so that Qt cleans up for you later.

Your delegate should derive from QStyledItemDelegate to get the best match to the host environment.

See if that gets you any further.