

And the pen join defines how two lines join when multiple connected lines are drawn. The pen cap defines how the end points of lines are drawn. Setting the style to none ( Qt::NoPen) tells the painter to not draw lines or outlines. The default style is solid ( Qt::SolidLine). PenJoinLabel - >setBuddy(penJoinComboBox) PenJoinLabel = new QLabel(tr( "Pen &Join:")) PenJoinComboBox - >addItem(tr( "Round"), Qt ::RoundJoin) PenJoinComboBox - >addItem(tr( "Bevel"), Qt ::BevelJoin) PenJoinComboBox - >addItem(tr( "Miter"), Qt ::MiterJoin) PenCapLabel = new QLabel(tr( "Pen &Cap:")) PenCapComboBox - >addItem(tr( "Round"), Qt ::RoundCap) PenCapComboBox - >addItem(tr( "Square"), Qt ::SquareCap) PenCapComboBox - >addItem(tr( "Flat"), Qt ::FlatCap) PenStyleLabel - >setBuddy(penStyleComboBox) PenStyleLabel = new QLabel(tr( "&Pen Style:")) PenStyleComboBox - >addItem(tr( "None"), static_cast ( Qt ::NoPen)) PenStyleComboBox - >addItem(tr( "Dash Dot Dot"), static_cast ( Qt ::DashDotDotLine)) PenStyleComboBox - >addItem(tr( "Dash Dot"), static_cast ( Qt ::DashDotLine)) PenStyleComboBox - >addItem(tr( "Dot"), static_cast ( Qt ::DotLine)) PenStyleComboBox - >addItem(tr( "Dash"), static_cast ( Qt ::DashLine)) PenStyleComboBox - >addItem(tr( "Solid"), static_cast ( Qt ::SolidLine)) the different shapes a QPainter can draw). Then we create the Shape combobox, and add the associated items (i.e. ShapeComboBox - >addItem(tr( "Pixmap"), RenderArea ::Pixmap) įirst we create the RenderArea widget that will render the currently active shape. ShapeComboBox - >addItem(tr( "Text"), RenderArea ::Text)

ShapeComboBox - >addItem(tr( "Points"), RenderArea ::Points) ShapeComboBox - >addItem(tr( "Arc"), RenderArea ::Arc) ShapeComboBox - >addItem(tr( "Polyline"), RenderArea ::Polyline)

ShapeComboBox - >addItem(tr( "Line"), RenderArea ::Line) ShapeComboBox - >addItem(tr( "Path"), RenderArea ::Path) ShapeComboBox - >addItem(tr( "Chord"), RenderArea ::Chord) ShapeComboBox - >addItem(tr( "Pie"), RenderArea ::Pie) ShapeComboBox - >addItem(tr( "Ellipse"), RenderArea ::Ellipse) ShapeComboBox - >addItem(tr( "Rounded Rectangle"), RenderArea ::RoundedRect) ShapeComboBox - >addItem(tr( "Rectangle"), RenderArea ::Rect) ShapeComboBox - >addItem(tr( "Polygon"), RenderArea ::Polygon) In the constructor we create and initialize the various widgets appearing in the main application window. And the brushChanged() slot updates the RenderArea widget when the user changes the painter's brush style.

We call the penChanged() slot when either of the QPainter's pen parameters changes. We declare the various widgets, and three private slots updating the RenderArea widget: The shapeChanged() slot updates the RenderArea widget when the user changes the currently active shape. The Window class inherits QWidget, and is the application's main window displaying a RenderArea widget in addition to several parameter widgets.
