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 problem
Qt 6.11 is out! See what's new in the release blog

QTcpSocket problem

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.6k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello guys...
    I have to mention that I'm new to Qt. Now I am trying to develop an interface for a Chess Game Client. The problem is the following...I have a login dialog, that gets input from the user, the address, and the port. With that information, I created a QTcpSocket, which was used to connect to the host. But, my problem is that, I have a main window that need that socket in order to communicate with the server. How can I do this. Also, if someone can offer some advices in creating the Chess Game.
    Thanks

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      probably something like this:

      declaration in your *.h file:
      @
      class YourChessDialog : public QDialog
      {
      ...
      private slots:
      void connectToServer();
      ...
      QTcpSocket tcpSocket;
      ...
      };
      @
      definition in your *.cpp file:
      @
      void YourChessDialog::connectToServer()
      {
      tcpSocket.connectToHost("your_internet_address", your_port_number);
      // ie: "chessserver.com", 2345
      }
      @
      And don't forget to close your connection.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Thanks, broadpeak, I will try what you gaved me.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          This is for login dialog, but for connecting the socket, to the other dialog? I mean, yea, this looks similar to what I have in the login dialog, but how to connect, the resulting socket, from this, to the second dialog? Thanks alot.

          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 Extensions
          • Unsolved