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. QTcpSocket / QTcpServer, connection closed
Forum Updated to NodeBB v4.3 + New Features

QTcpSocket / QTcpServer, connection closed

Scheduled Pinned Locked Moved Solved General and Desktop
42 Posts 6 Posters 7.6k Views 3 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.
  • SPlattenS SPlatten

    @KroMignon , How can you possibly know what I'm trying to do, of course I want to understand it.

    The issue is I have such a lot of work ahead of me that I just don't have the luxury of spending hours on one particular problem.

    KroMignonK Offline
    KroMignonK Offline
    KroMignon
    wrote on last edited by KroMignon
    #41

    @SPlatten said in QTcpSocket / QTcpServer, connection closed:

    The issue is I have such a lot of work ahead of me that I just don't have the luxury of spending hours on one particular problem.

    In french we say "Il ne faut pas confondre vitesse et précipitation!", could be translate with "Speeding up is not the same as rushing. "

    We don't have the same perception about "losing time".
    I believe that spending 5~10 minutes to understand the Qt "basics" will helps you to save even more time later to not have to undo and redo what you have done and not works properly.

    But this is up to you, which you good luck for your development.

    It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

    1 Reply Last reply
    5
    • SPlattenS SPlatten

      @JKSH The intention is that any complexity is hidden and the end result is much cleaner and easier to use.

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #42

      @SPlatten said in QTcpSocket / QTcpServer, connection closed:

      @JKSH The intention is that any complexity is hidden and the end result is much cleaner and easier to use.

      I was referring to the complexity of your implementation. Its complexity made it hard for you to understand where your errors were coming from.

      I believe you'll have better success in the future if you start learning a new class by implementing simple and "lean" code from scratch first, make sure it works correctly first, and then gradually add more features on top.

      Furthermore, you can hide complexity without subclassing/inheritance. You could hide the QTcpServer as a member variable of another class instead. We should often prefer composition over inhertance -- If you took this approach, you wouldn't have needed addPendingConnection()and you would've avoided the issues you raised in this thread.

      I have such a lot of work ahead of me that I just don't have the luxury of spending hours on one particular problem.

      Please understand: @KroMignon's concerns are not specific to this particular problem. He's asking you to develop an understanding of some foundational concepts of C++ and QObjects which apply to most of your code -- not just TCP-related code.

      Do you understand now? In this line clsSocketClient* pClient = new clsSocketClient(new QTcpSocket()); :

      1. What does new clsSocketClient() do?
      2. What does new QTcpSocket() do?
      3. What happens when you pass new TcpSocket() into the constructor of your clsSocketClient?
      4. What happens when you pass nullptr into the constructor of your clsSocketClient?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      5

      • Login

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