I honesty don't see a way around this that doesn't involve some rather drastic measures for such a cosmetic anomaly. We're currently relying on the built-in "edit" feature of QAbstractView (inherited by QTreeView) to do the renaming. Unless I'm missing something obvious, being able to handle the situation where a rename is canceled by clicking the mouse outside of the edit area would involve creating our own custom editor widget either through subclassing or by using a QStyledItemDelegate just to be able to install an event filter that captures the stray rename-"canceling" mouse-click.
My advice? Just train ourselves to hit ESC to cancel a rename instead.