$30
Assignment 2
Redesign your “piggy” application. It should look like:
1. The top-level widget for the application should be a subclass of QMainWindow. Hint:
QMainWindow takes only one container, and you attach it with:
mainWindow-setCentralWidget(container-widget);
2. As your layout for container-widget, you should use the QGridLayout layout from
assignment 1 with the layout of the buttons above. All that should be in your main() is the
constructor for your subclass of QMainWindow. ( The main will also include the bookkeeping of
creating a Qapplication, the show(), and the main event loop.)
3. You may choose the margins for the buttons and any white space. You may take the defaults.
4. Each button 1-6, when pressed, should provide a dialog box with the text being “button j: the
piggy nursery rhyme text”, where j is the button number and the text is from the rhyme. There is
a sixth button as well, as in assignment 1 . All dialog boxes should be modal (meaning a dialog
box blocks until the user deals with it), and you may choose your favorate kind of message box.
(The diagram has an information box.) The quit button, strangely enough, will exit the
application.
(the button should have been button 3)
5. The piggy buttons need to be a single subclass of QPushButton or QToolButton; there must be
only one subclass with multiple instances. There should be no text or button number hardwired
into the subclass.
6. You must put the slot and connect for the dialog box (for the signal-slot mechanism) in the
button subclass. There must be a maximum in your application of one slot for the dialog output
and one for the exit/quit. Hint: It will be easier for you to make quit button be a normal
QPushButton, since the piggy buttons must have the connect statement in the subclass.
7. You are not allowed to use a GUI builder (e.g., Qt Designer). You must hand-code this assignment.
8. You will be graded on basic functionality – correct use of subclasses, hooking in the events
(signals and slots) appropriately, output, and correct layout (including the capability resize
appropriately).
9. You are responsible for monitoring the Canvas site for any modifications or corrections of this
assignment (or any assignment).
Mark Ackerman 9/22/2015 6:34 PM
Deleted: container
Mark Ackerman 9/22/2015 6:34 PM
Formatted: Font:(Default) Courier New
Mark Ackerman 9/22/2015 6:34 PM
Deleted: 5
Mark Ackerman 9/22/2015 6:40 PM
Deleted:
This is due Sunday 9/27 at 11:55pm. You must upload your code to Canvas to submit. Same rules as
assignment 1 on the naming and format of the submission.
Again, this should be pretty straightforward. If anything is taking a long time, you should ask for help.
To startup in QtCreator: See assignment 1.
If you’re not familar with the piggy nursery rhyme, it is a nursery rhyme used to play with a child’s
foot. In the case of 493, the child has six toes:
this little piggy went to market,
this little piggy stayed home,
this little piggy ate roast beef,
this little piggy had none,
this little piggy cried wee wee wee,
this little piggie cried go blue