Example Qt Chat Program

A few months ago I gave a presentation to the BYU Unix Users Group on Qt GUI development. During the meeting, we created a simple chat room program called chatterbox. At the time I promised to post my source code with comments, a promise on which I am now making good.

Here is the code. Instructions for building and running it are below:

The client source code (chatterbox.zip)
The server source code (chatterboxd.zip)

Build Instructions

You’ll need to install Qt for your operating system, at least version 4.3 or newer. Make sure “qmake” is in your path. On Windows, you’ll also want Visual Studio 2008 Express. Then, download and unzip the two zip files above. I’ll wait here while you do that.

Building the Server

  1. Open your favorite terminal (on Windows, use “Qt command prompt” in the start menu)
  2. cd into the chatterboxd directory
  3. Run qmake (you should see no output if it suceeds)
  4. Run make (or nmake on Windows — it will produce a lot of output and hopefully run error free)
  5. Run ./chatterboxd (or debug\chatterboxd.exe on Windows)
  6. It should print Ready when it’s ready to go.

Building the Client

Build the client the same way. Note, it’s the chatterbox (no “d” on the end) directory.

What it Looks Like

Here’s what the client looks like when you run it:


Getting Help

If you can’t get this to build or are running into some other problem, just leave a comment below, and I’ll get to it as soon as possible.

Write a Reply or Comment

Your email address will not be published.