I have QWidget in QScrollArea. I have one push button in the MainWindow. I want to add QWidgets dynamically to the exixsting QWidget on pushbutton clicked. Please help me.
Mythili
I have QWidget in QScrollArea. I have one push button in the MainWindow. I want to add QWidgets dynamically to the exixsting QWidget on pushbutton clicked. Please help me.
Mythili
Set a layout on the QWidget (the one in QScrollArea), and add the new dynamic widgets to the layout in a slot connected the QPushButton signal clicked()
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
Thank u very much. Its working. I want to perform the same functions which i am doing for first QWidget which is created using ui. That functions are in seperate .cpp file.
Now I am ading this dynamic widgets in mainwindow. How to perform those functions after creating QWidget dynamically in click event.
Please help me.
Make those functions a slots and connect to the button click signal (not event)
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
Hi Santosh.
I only get one widget in the scroll area rather than multiple ones for every instance:
Controls is just a row of label, progressbar and checkbox. The signal emitted updates the label. As I said, there is only one row for every call of the method. The layout is made in the designer.void MainWindow:n_actionFile_triggered()
{
QTime t = QTime::currentTime();
ctls = new Controls();
connect(this, SIGNAL(UpdateInfo(int)), ctls, SLOT(WriteInfoNumber(int)));
ui->scrollArea->setWidget(ctls);
emit UpdateInfo(t.msecsSinceStartOfDay());
}
Last edited by astodolski; 16th February 2014 at 20:02. Reason: More info
Bookmarks