[Interest] Can I update contents in QScrollArea dynamically?

Zhang, Li tornadory at 163.com
Thu Nov 1 14:04:25 CET 2012


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++){
        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);\
                                   }\
                                   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 and add new ones.


Anyone can give some suggestions?   Thanks in advance!



--

 Best Regards,




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121101/84d57dac/attachment.html>


More information about the Interest mailing list