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)
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
- Open your favorite terminal (on Windows, use “Qt command prompt” in the start menu)
- cd into the chatterboxd directory
- Run qmake (you should see no output if it suceeds)
- Run make (or nmake on Windows — it will produce a lot of output and hopefully run error free)
- Run ./chatterboxd (or debug\chatterboxd.exe on Windows)
- 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:
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.