Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTcpServer, I can't use the main event loop
Forum Updated to NodeBB v4.3 + New Features

QTcpServer, I can't use the main event loop

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 298 Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Merlino
    wrote on last edited by
    #1

    Hello,

    I need to add a TCP server to a large linux application which was developed in the past by others.
    For reasons that I haven't had time to fully investigate, the internal app thread structure blocks the main loop of QT events and I can't change the structure without heavy refactoring.

    I then tried to implement the TCP server in a separate thread by overriding "incomingConnection", but the method is not called, I think why the events loop is still required internally (with the event loop fully working this implementation work). Do you have any idea how this problem can be solved?

    I have seen that a new QEventLoop can be created, but I am not sure if it could solve it.
    If it were possible I would much prefer to use signals and slots, which make the code simpler and more performing.

    jsulmJ 1 Reply Last reply
    0
    • M Merlino

      Hello,

      I need to add a TCP server to a large linux application which was developed in the past by others.
      For reasons that I haven't had time to fully investigate, the internal app thread structure blocks the main loop of QT events and I can't change the structure without heavy refactoring.

      I then tried to implement the TCP server in a separate thread by overriding "incomingConnection", but the method is not called, I think why the events loop is still required internally (with the event loop fully working this implementation work). Do you have any idea how this problem can be solved?

      I have seen that a new QEventLoop can be created, but I am not sure if it could solve it.
      If it were possible I would much prefer to use signals and slots, which make the code simpler and more performing.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @Merlino said in QTcpServer, I can't use the main event loop:

      Do you have any idea how this problem can be solved?

      You can have Qt event loop in the thread where you're using QTcpServer: https://doc.qt.io/qt-5/qeventloop.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3

      • Login

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