Hi,
Thank You for your reply..
Added after 1 48 minutes:
Hi ,
I have a mainwindow in which i have one spinbox ,button and a frame . If i press button ,I want to add as many buttons as i select in spinbox ,say 5, to the frame with a layout. My code
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
layout = new QVBoxLayout;
ui->frame->setLayout(layout);
connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(getvalue() ));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::getvalue()
{
qDebug() << "value "<<ui->spinBox->value();
int i = ui->spinBox->value();
QPushButton *button[5];
for(int j=0;j<i;j++)
{
button[j] = new QPushButton;
layout->addWidget(button[j]);
}
}
But this code adds each button to the frame every time i press button as I am not deleting the widget from the layout or frame. How can I do this ?? Please help..:)