Hi I am trying to add list of QGraphicsItem into QGraphicsScene by this code...
int position=0;
int numberOfCards=xAxe*yAxe;
for (qreal i=0; i<xAxe*myWidthCard; i+=myWidthCard){
for (qreal j=0; j<yAxe*myHeightCard; j+=myHeightCard){
Item *item=list[position];
item->setPos(item->pos().x()+i, item->pos().y()+j);
outputScene->addItem(item);
position++;
}
}
int position=0;
int numberOfCards=xAxe*yAxe;
for (qreal i=0; i<xAxe*myWidthCard; i+=myWidthCard){
for (qreal j=0; j<yAxe*myHeightCard; j+=myHeightCard){
Item *item=list[position];
item->setPos(item->pos().x()+i, item->pos().y()+j);
outputScene->addItem(item);
position++;
}
}
To copy to clipboard, switch view to plain text mode
Could someone help me, why this code dont add item to Scene?
I dont want to use "foreach"
this code is OK
foreach (Item *listItem, list) {
listItem->setPos(listItem->pos().x()+x, listItem->pos().y()+y);
outputScene->addItem(listItem);
x+=myWidthCard; j++;
if(j==xAxe){
y+=myHeightCard; x=0; j=0; i++;
}
if(i==yAxe){
y=0; i=0;
}
}
foreach (Item *listItem, list) {
listItem->setPos(listItem->pos().x()+x, listItem->pos().y()+y);
outputScene->addItem(listItem);
x+=myWidthCard; j++;
if(j==xAxe){
y+=myHeightCard; x=0; j=0; i++;
}
if(i==yAxe){
y=0; i=0;
}
}
To copy to clipboard, switch view to plain text mode
thanks for answers
Bookmarks