QPen pen(Qt::black, 2.0, Qt::SolidLine, Qt::RoundCap);
QPen pen(Qt::blue, 1.5, Qt::DashLine, Qt::SquareCap);In this example, we are creating a pen object with a blue color, a thickness of 1.5, and a dashed line style with a Square capStyle. These examples show how QPen's capStyle property can be used to customize the line ending style of the pen object. The Qt framework library contains the QPen class.