amulya
5th October 2006, 11:53
hi there,
i m trying to add an array of radio buttons in a grid layout and then further into a widget. but these radio buttons seem to overlap over each other. Thus in the output, there is only one radio button. Here is the code
KPH_WIDGET::KPH_WIDGET(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
QPalette objPalette1;
objPalette1.setColor(QPalette::Window,Qt::white);
QPalette objPalette2;
objPalette2.setColor(QPalette::Window,Qt::gray);
//setFixedSize(300,300);
QGridLayout* pGridLayout = new QGridLayout(this);
CRadioButtonEx* arr[10] ;
for(int i = 0; i < 10; i++)
{
pGridLayout->setRowMinimumHeight(i,50);
arr[i] = new CRadioButtonEx(tr("check"),this);
if(arr[i])
{
if(i%2 == 0)
arr[i]->setPalette(objPalette1);
else
arr[i]->setPalette(objPalette2);
arr[i]->setAutoFillBackground(true);
}
pGridLayout->addWidget(arr[i],i,0,Qt::AlignLeft);
}
Here, CRadioButtonEx is a customized radio button which works correctly. On debugging, it shows that all the 10 of the radio buttons are created. But only one is shown.
Looking forward to a reply.
Cheers,
Amulya
i m trying to add an array of radio buttons in a grid layout and then further into a widget. but these radio buttons seem to overlap over each other. Thus in the output, there is only one radio button. Here is the code
KPH_WIDGET::KPH_WIDGET(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
QPalette objPalette1;
objPalette1.setColor(QPalette::Window,Qt::white);
QPalette objPalette2;
objPalette2.setColor(QPalette::Window,Qt::gray);
//setFixedSize(300,300);
QGridLayout* pGridLayout = new QGridLayout(this);
CRadioButtonEx* arr[10] ;
for(int i = 0; i < 10; i++)
{
pGridLayout->setRowMinimumHeight(i,50);
arr[i] = new CRadioButtonEx(tr("check"),this);
if(arr[i])
{
if(i%2 == 0)
arr[i]->setPalette(objPalette1);
else
arr[i]->setPalette(objPalette2);
arr[i]->setAutoFillBackground(true);
}
pGridLayout->addWidget(arr[i],i,0,Qt::AlignLeft);
}
Here, CRadioButtonEx is a customized radio button which works correctly. On debugging, it shows that all the 10 of the radio buttons are created. But only one is shown.
Looking forward to a reply.
Cheers,
Amulya