< Back

Lecture 11- QT


As usual, create a directory to hold today's activities:

$ mkdir ~/cs170/labs/lab11 
$ cd ~/cs170/labs/lab11

QT

In today's lecture, I'm going to show you some additional QT stuff that will be useful not only for today's lab activities, but also for the next assignment. Make sure you take notes from today's lecture!



Lab Activity 1

By default, doing form based interactions with QT is very straight forward. However, it's very limiting to handling button presses, etc. QT has capabilities, behind the scenes, to give you much more control. These come from being able to modify the mouse click event handlers, and the keyboard key press handlers. To start off, we will make an incomplete Sudoku program which will allow you to interact with a grid of labels!

Details

Using QTCreator, create a C++ program that displays a 9 x 9 grid of labels, all evenly spaced and sized. Your grid of labels should fill as much of the window as possible. They should appear blank by default. Whenever the user clicks on a label, it should be "selected," and a border should appear around it. Once a label is selected, the user should be able to press one of the keyboard keys and display a number in the selected label. If the user presses a key which is not a number, nothing should appear in the label.

In addition, your program should identify any locations which produce conflicts with one another on a row or a column level. You can ignore the "block" level conflicts.

Example

 

Challenge

Your game is only partially functional right now. It doesn't even check to see if you've got a solved puzzle! Add checks to your program that highlights block level conflicts.

If you are feeling ambitious, you use file redirection in order to load a text file via standard input: