|
Homework 3: Paint
|
Project Description
In this assignment, you will implement a (simplified) "Paint" to learn about gui Programming with Qt. You will
use object-oriented technique to implement "Paint". After this project, you are expected to learn how to develop
a Qt GUI program and look for materials by yourself from the Qt API Reference.
Project Requirement
You need to finish the following in your program:
-
Create a menu bar that support the following functions:
(3 pts)
--Create a new image
--Load a bitmap file
--Save current image as bitmap file
--Allow user to choose Foreground and Background color (Foreground color means the color used to draw
stuff, i.e. color of the pen. Background color means the color of a new image you create.
There is no need to change the background color of the existing image. The new background color only
needs to be applied to the next new image you create.)
--Support 1 level undo and redo
--Clear the image
--Display the toolbar
-
Create a tool bar that contains shortcuts of tools. You need to inherit from Qt::QToolBar to implement your
own toolbar. Your toolbar should behave exactly like the toolbar in the sample program.
(2 pts)
-
Overload the following mouse event handler to handle the corresponding mouse events:
(3 pts)
//Left click: Drawing, Right Click: popup the properties dialog of current tool
void mousePressEvent (QMouseEvent *);
//Draw the image when user dragging the mouse after Left Click
void mouseMoveEvent (QMouseEvent *);
//Confirm the drawing
void mouseReleaseEvent (QMouseEvent *);
//For terminating the drawing of polyline
void mouseDoubleClickEvent(QMouseEvent *);
Here are the right-click screenshots of the dialogs:
-
You need to implement two kinds of tools: Pen, Line. For each kind of tools, create a properties dialog that
allow user to modify the properties of tool. You need to inherit from QDialog to implement your own dialog,
and use QRadioButton, QButtonGroup and QSlider to implement the slider and button. (try the sample program;
when you right-click on the Pen or Line Icon, its dialog will show up. You should do the same thing.)
(2 pts)
To draw on an image, you need to see the API of QPainter, QPen, QBrush and QPixmap. Note the differences between
drawing on a widget and an image.
|