How to set the widget class to none in c++

You can’t use SetWidetClass. You have to do it more manually like the code I showed you above.
Your code crashes because SetWidetClass internally spawns a widget from the passsed class and then sets it. If its passed nullptr then it crashes on the spawn process.

Do it manually like I showed you and it will run ok.