所以我找到了this code works:
class DrawImage(QtWidgets.QWidget):
def __init__(self, parent):
QtWidgets.QWidget.__init__(self, parent)
self.move(150,50)
self.setFixedSize(100,100)
self.startA = 5
self.endA = 30
def paintEvent(self, event): #use to draw on the canvas
paint = QtGui.QPainter()
paint.begin(self)
paint.setRenderHint(QtGui.QPainter.Antialiasing)
# make a white drawing background
paint.setBrush(QtCore.Qt.white)
paint.drawRect(event.rect())
paint.setPen(QtCore.Qt.black)
paint.setBrush(QtCore.Qt.white)
paint.drawEllipse(QtCore.QRect(25, 25, 50, 50)) #outer circle
paint.setPen(QtCore.Qt.yellow)
paint.setBrush(QtCore.Qt.yellow)
paint.drawEllipse(QtCore.QRect(37.5, 37.5, 25, 25)) #middle circle
paint.setPen(QtCore.Qt.white)
paint.setBrush(QtCore.Qt.white)
paint.drawEllipse(QtCore.QRect(43.75, 43.75, 12.5, 12.5)) #innermost circle
#where I am trying to implement a half circle
r = QtCore.QRect(12.5, 12.5, 20, 20) #<-- create rectangle
size = r.size() #<-- get rectangle size
r.setSize(size*10) #<-- set size
startAngle = self.startA*16 #<-- set start angle to draw arc
endAngle = self.endA*16 #<-- set end arc angle
paint.setPen(QtCore.Qt.black) #<-- arc color
paint.setBrush(QtCore.Qt.yellow)
paint.drawArc(r, startAngle, endAngle)
paint.end()
这是正式合法的吗?我以为我在这里做一个int foo[] = {0, foo[0] + 1, foo[1] + 2, foo[2] + 4 };
,但是如果我可以访问先前初始化的元素,则必须进行聚合初始化。
我试图找到关于此行为合法性的官方声明,但我似乎没有。