A similar problem was reported here:Error running example B1: qt.qpa.xcb: could not connect to display
and some resolution externally here:
These were on Ubuntu within WSL, but there are some things to try in that latter post related to checking that the X server is running.