我有这个结构:
typedef struct {
QPolygon polygon;
QRect position;
} form;
我尝试forms
如下初始化,但出现分段错误错误:
int n = 10
forms = (form*) malloc(sizeof(form) * n);
while (n>0) {
forms[n].position.setRect(0,0,0,0);
forms[n].polygon=QPolygon(0); //error - segmentation fault
forms[n].polygon = QPolygon(QRect(x, y, w, h)); //error - segmentation fault
}
我也尝试这样:
QPolygon v;
v = QPolygon(QRect(x, y, w, h)); //ok
v = QPolygon(QRect(x, y, w, h)); //ok
sprites[n].polygon = QPolygon(QRect(x, y, w, h)); //error - segmentation fault
如何将多边形放入结构中?