Hi Li,
This seems to be a common mistake - adding widgets directly to the QScrollArea as child widgets, rather than using its setWidget. Read the docs - they are very clear. Tony. From: interest-bounces+tony=rightsoft.com...@qt-project.org [mailto:interest-bounces+tony=rightsoft.com...@qt-project.org] On Behalf Of Zhang, Li Sent: Friday, 2 November 2012 12:04 AM To: interest@qt-project.org Subject: [Interest] Can I update contents in QScrollArea dynamically? Hi All, I want to use a QScrollArea as a container of several buttons[or other components], and then I need to replace all of these buttons with new(also the amount of buttons is different). Current, I just add buttons to the QScrollArea, but can not remove all of them and update with new buttons... groupBox = new QGroupBox(ui->GCultureDetailedScrollArea); groupLayout = new QGridLayout(groupBox); groupBox->setLayout(groupLayout); groupLayout->setVerticalSpacing(15); groupLayout->setHorizontalSpacing(10); for(int i = 0; i < 50; i++){ < div> for(int j = 0; j < 3; j++){ QString buttonName = QString("button%1").arg(i+1); QPushButton *pbutton = new QPushButton(buttonName); //pbutton->resize(130, 40); pbutton->setMinimumWidth(140); pbutton->setMinimumHeight(40); pbutton->setStyleSheet("\ QPushButton{\ border-image: url(./pictures/button_groupactivities.png);\ &nb sp; }\ QPushButton:pressed {\ border-image: url(./pictures/button_groupactivities_clicked.png);\ }\ "); groupLayout->addWidget(pbutton, i, j); } } So now how can I remove all of buttons in groupLayout an d add new ones. Anyone can give some suggestions? Thanks in advance! -- Best Regards,
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest