Anshuman
21st April 2011, 07:06
hello friends
I am creating an array of buttons having 7 rows 7 colums..
now i trying to display first seven buttons in one row after which it goes to second row and display next seven button..and so on..
i have wrriten a code for this..its working but problem is that all the buttons are displayed in one row only..so if anyone suggest me to resolve that problem..
i am sending my code along with this..
QWidget *centralWidget = new QWidget;
selectedDate=QDate::currentDate();
int count=1,i,j;
QPushButton *button[10][10];
QHBoxLayout *controlsLayout = new QHBoxLayout;
for(i=0;i<7;i++)
{
for(j=0;j<7;j++)
{
if(count<=42)
{
button[i][j] = new QPushButton("p");
button[i][j]->resize(40,40);
button[i][j]->move(40*j, 40*i);
button[i][j]->show();
controlsLayout->addWidget(button[i][j]);
centralWidget->setLayout(controlsLayout);
setCentralWidget(centralWidget);
count++;
}
}
}
}
I am creating an array of buttons having 7 rows 7 colums..
now i trying to display first seven buttons in one row after which it goes to second row and display next seven button..and so on..
i have wrriten a code for this..its working but problem is that all the buttons are displayed in one row only..so if anyone suggest me to resolve that problem..
i am sending my code along with this..
QWidget *centralWidget = new QWidget;
selectedDate=QDate::currentDate();
int count=1,i,j;
QPushButton *button[10][10];
QHBoxLayout *controlsLayout = new QHBoxLayout;
for(i=0;i<7;i++)
{
for(j=0;j<7;j++)
{
if(count<=42)
{
button[i][j] = new QPushButton("p");
button[i][j]->resize(40,40);
button[i][j]->move(40*j, 40*i);
button[i][j]->show();
controlsLayout->addWidget(button[i][j]);
centralWidget->setLayout(controlsLayout);
setCentralWidget(centralWidget);
count++;
}
}
}
}