With QTcpServer, you can set up authentication for client with some basic username:password
pair at the start. As soon as the connection is established, ask or wait for the username:password
to be sent over to the Server. Verify it. In case of invalid data or timeout, close the connection.
As far as the login page is concerned, you need to host that on the Server and you'll be dealing in HTTP protocol instead of TCP. Take a look at QHttp. That'll get you started.
For Qt, there are other options too. You just have to lay down your requirements and find the one that might fulfill those e.g. Wt.