我有一个代码,用于生成Qt场景中的卡片项目.这是我到目前为止所提出的.调用的成员函数正是您从名称中派生的函数,因此我不需要在此处包含它们.
// creating the cards
int x = 0;
int y = 0;
int line_brake = 0;
for(int i = 0; i < width; i++)
{
for(int j = 0; j < width; j++)
{
card = new Card();
int card_width = card->getWidth();
int card_height = card->getHeight();
if(j == (width-1))
{
line_brake = 1;
}
else if((j != (width-1)) && (line_brake == 1))
{
y += card_height;
card->setPos(x,y);
line_brake = 0;
x = 0 - card_width;
}
else
{
card->setPos(x,y); …Run Code Online (Sandbox Code Playgroud)