dcsimg
Linux Today: Linux News On Internet Time.




More on LinuxToday


LinuxWorld: Geek Bowl on the Qt - Out-of-box features impress our resident game show host

Aug 19, 2000, 01:37 (0 Talkback[s])
(Other stories by Nicholas Petreley)

WEBINAR:
On-Demand

Re-Imagining Linux Platforms to Meet the Needs of Cloud Service Providers


"I just put the finishing touches on the Geek Bowl quiz program, and I must say that it has been a rewarding experience writing this program in Qt. In the past week I was able to rip out a couple of custom classes I'd written and replace them with stock objects that Qt provides. I wrote my custom classes because I didn't realize quite how much Qt can do right out of the box. Of the two special classes, one displayed pictures and scaled them on demand, and the other displayed animations. It turns out that I created them unnecessarily, since you can make a label (the Qt object QLabel) that automatically displays pictures or animations. All you have to do is flip a switch and the label scales the graphics for you. The method for that is QLabel->setScaled(TRUE). In the end, I decided not to use animations in the Geek Bowl, but I've filed away the knowledge on how to do it for future use."

"I also changed the behavior of the program for a very embarrassing reason. I simply couldn't think of enough questions to fill all four categories (easy, medium, hard, and bizarre) in a way that would ensure that we wouldn't run out of questions in any single category. So I changed the game rules. Instead of allowing the contestants to pick from the four categories (which would give them the opportunity to deplete a single category quickly), the program automatically cycles through the categories one by one. I like the way this worked out, because it gave me the opportunity to create a few question themes. For example, the program poses four questions about The Hitchhiker's Guide to the Galaxy, going from the easy to the bizarre."

"One of the biggest problems I ran into was finding a good way to play sounds during the show. At one point, I noticed a Qt class called QSound that would do everything I needed. But I couldn't get it to work. Then I realized that I was looking at beta documentation for Qt 2.2. I'm using Qt 2.1, and there is no QSound class in Qt 2.1 or earlier. I'm not sure how I managed to get Qt 2.2 beta documentation on my machine, but that's a mystery I didn't have time to solve."

Complete Story

Related Stories: