From kde-devel Wed Jun 07 04:47:23 2006 From: "Jaldhar H. Vyas" Date: Wed, 07 Jun 2006 04:47:23 +0000 To: kde-devel Subject: how do I implement dynamic radio buttons in a dialog? Message-Id: X-MARC-Message: https://marc.info/?l=kde-devel&m=115004665225518 Any help with this problem would be gratefully received. In a dialog box I need to dynamically create radio buttons at runtime based on a variable number of items. In the following code, ui is the class derived from my .ui file. items as you can see is a QMap. The keys of this QMap should be the labels of my radio buttons. btngrp is is a QButtonGroup which should contain my radio buttons vertically. (Related question: why won't Qt Designer let me create a QVButtonGroup?) for (QMap< QString, int >::const_iterator it = _items.begin(); it != _items.end(); it++) { int id = ui->btngrp->insert(new QRadioButton(it.key(), reinterpret_cast(ui->btngrp->parent()))); ui->btngrp->find(id)->show(); } This works but the newly created radio buttons are not arranged neatly but stacked on top of each other in the top left of the button group. What to do I need to do to make them appear in a single column? Is it because I didn't use a QVButtonGroup? Do my radio buttons have the wrong parent? Or is it something else altogether? I am using Qt 3.3.6 and KDE 3.5.3 on Kubuntu Dapper. -- Jaldhar H. Vyas >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<