[Qt-interest] ID's on QButtonGroup
Frank Lutz
frank422542 at googlemail.com
Sun May 24 10:27:09 CEST 2009
Hi,
i do have some Problems with the id's of QButtongroup. Firsty i put
Buttons with Directory Names into and
than one empty for QLineEdit ( for new Directory ).
Later i want destroy the Buttons and fill new, but my last empty button
didn't destroyed.
So i ask myself why he didn't distroy also the last Button. Do you can
help me please?
Thanks!
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Source Code:
for (int i = 0; i < dirlist.size(); i++) {
qDebug()<<" dirlist.at("<<i<<").baseName()="<<dirlist.at(i).baseName();
QRadioButton *btn = new QRadioButton(" "+dirlist.at(i).baseName() );
btn->setAutoExclusive(true);
buttongroup->addButton(btn,i);
if(dirlist.at(i).baseName()==value){
buttongroup->button(0)->setChecked(true); }
}
QRadioButton *btn = new QRadioButton();
btn->setAutoExclusive(true);
qDebug()<<" buttongroup->buttons ().size()="<<buttongroup->buttons
().size();
int id = buttongroup->buttons ().size();
buttongroup->addButton(btn,id);
qDebug()<<" buttongroup->buttons"<<buttongroup->buttons();
---------------------------------------------------------------------------------------------------------------------
Debug:
buttongroup->buttons ().size()= 2
buttongroup->buttons (QRadioButton(0x815da20) ,
QRadioButton(0x8153308) , QRadioButton(0x813be20) )
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
...
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Source Code:
qDebug()<<"
buttongroup->buttons().size()="<<buttongroup->buttons().size()<<endl;
for(int i=0; i<buttongroup->buttons().size();i++){
qDebug()<<" i="<<i<<"destroy
buttongroup->button("<<i<<")->text()="<<buttongroup->button(i)->text();
buttongroup->removeButton(buttongroup->button(i));
}
---------------------------------------------------------------------------------------------------------------------
Debug:
buttongroup->buttons().size()= 3
i= 0 destroy buttongroup->button( 0 )->text()= " Cocktails"
i= 1 destroy buttongroup->button( 1 )->text()= " Vorspeisen"
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
More information about the Qt-interest-old
mailing list