When I removed all the code and left only a declaration of the QWebSocket type variable in the code, I got the following error. I am including <QtWebSockets/QWebSocket> and added websockets to my qmake. I added -lwebsocket.js to make arguments in the creator as well.
The -lwebsocket.js seems to be the problem. I tried to build a minimal project w/ WebSocket outside Qt, using the emscripten API and I received a similar error when I did not include -lwebsocket.js into the build command. Apparently, when using Qt creator the compiler is not receiving the argument, regardless of where I'll put it. I tried adding it to the .pro file in several ways as well (using: QMAKE_LFLAGS, QMAKE_CXXFLAGS, LIBS, CONFIG)
error: undefined symbol: _ZN10QWebSocketC1ERK7QStringN18QWebSocketProtocol7VersionEP7QObject (referenced by top-level compiled C/C++ code)
warning: Link with -sLLD_REPORT_UNDEFINED to get more information on undefined symbols
warning: To disable errors for undefined symbols use -sERROR_ON_UNDEFINED_SYMBOLS=0
warning: __ZN10QWebSocketC1ERK7QStringN18QWebSocketProtocol7VersionEP7QObject may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZN10QWebSocketD1Ev (referenced by top-level compiled C/C++ code)
warning: __ZN10QWebSocketD1Ev may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
em++: error: '
/emsdk/node/14.18.2_64bit/bin/node /emsdk/upstream/emscripten/src/compiler.js /var/folders/qn/gzn_l03x2ds1cdh94cysrhfw0000gq/T/tmp4su37te2.json'