Try these questions to test your knowledge from this chapter:
- Add code to this method to write your name in blue on the bottom of the picture:
def create_headshot(self, image_file, name): image = qtg.QImage() image.load(image_file) # your code here # end of your code return image
- Given a QPainter object called painter, write a line of code to paint an 80 × 80 pixel octagon in the upper-left corner of the painter's paint device. You can refer to the documentation at https://doc.qt.io/qt-5/qpainter.html#drawPolygon for guidance.
- You're creating a custom widget and can't figure out why the text is showing up in black. The following is your paintEvent() method; see whether you can figure out the problem:
def paintEvent(self, ...