Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QtWebsocket mainwindow example
Qt 6.12 LTS is out! See what's new in the release blog

QtWebsocket mainwindow example

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ErgoDave
    wrote on last edited by
    #1

    I've recently explored the Non SSL Console version of the QtWebsocket server examples and as such I'm wondering about the approach to using the QtWebsocket server in a mainwindow application.

    This section of the Console version main.cpp
    bool debug = parser.isSet(dbgOption);
    int port = parser.value(portOption).toInt();
    EchoServer *server = new EchoServer(port, debug);
    QObject::connect(server, &EchoServer::closed, &a, &QCoreApplication::quit);

    I've tried unsuccessfully with mainwindow.cpp
    --within a ui(new Ui::MainWindow) statement:
    bool debug = false;
    quint16 port = 11192;
    server = new EchoServer(port,debug);
    QObject::connect(server, &EchoServer::closed, this, &QCoreApplication::quit);

    fails with LINK Errors:

    mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall EchoServer::EchoServer(unsigned short,bool,class QObject *)" (??0EchoServer@@QAE@G_NPAVQObject@@@Z) referenced in function "public: __thiscall MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QAE@PAVQWidget@@@Z)

    mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: void __thiscall EchoServer::closed(void)" (?closed@EchoServer@@QAEXXZ) referenced in function "public: __thiscall MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QAE@PAVQWidget@@@Z)

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      This indicates that EchoServer.cpp is not compiled or some build issue. I suggest you to clean(if possible remove) the build directory. Rebuild your application. It should work.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

      1 Reply Last reply
      0
      • E Offline
        E Offline
        ErgoDave
        wrote on last edited by
        #3

        Thanks for your suggestion. Earlier I had 'Cleaned All' without success. Using your suggestion: stripped out all the obj files manually and build the 'target' cpp separately which led to the project building successfully.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt
        • Unsolved