[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: how do I implement dynamic radio buttons in a dialog?
From: "Jaldhar H. Vyas" <jaldhar () braincells ! com>
Date: 2006-06-07 4:47:23
Message-ID: Pine.LNX.4.63.0606070031240.24115 () localhost ! localdomain
[Download RAW message or body]
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<QString, int>. 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<QWidget *>(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 <jaldhar@braincells.com>
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic