I am trying to do something that I thought it would be terribly easy : Adding QRadioButton into my QWizardPage without any layout.
The following code that adds QRadioButton is being called when user clicks button Next (signal currentIdChanged calls the code):
int newPositionY = 0;
for (vector<Events::VCS::PnPDevice>::const_iterator it=m_devices.begin(); it!=m_devices.end(); it++)
{
if (it->type == Events::VCS::HEADSET)
{
//add a radio button
stringstream text;
text << (it->name) << " " << (it->serialNumber);
QRadioButton* radioButton = new QRadioButton(ui.wpSINGLE_USER);
radioButton->setGeometry(50, 20 + newPositionY, 260, 40);
radioButton->setText(text.str().c_str());
newPositionY = newPositionY + 40
}
}
}
I added this little piece of code to see what is going on with my QRadioButton
QList<QRadioButton*> listButton = ui.wpSINGLE_USER->findChildren<QRadioButton*>();
int size = listButton.size();
QRect rect1 = listButton[0]->rect();
QRect rect2 = listButton[1]->rect();
I then realized that it seems that the problem might be QRect.
The value for rect1 and rect2 are erroneous. rect1 = (0, 0, 259, 39) and rect2 = (0, 0, 259, 39) Correct value for rect1 should be (50, 20, 260, 40) andn for rect2 (50, 60, 260, 40)
So, what is the problem, how to add QRadioButton into QWidget without layout?
EDIT
That is strange, if, instead of adding the QRadioButton into the QWizardPage when user clicks button next I am adding them into the QWizard contructor, it works.
Can somebody tell me why I am not able to add QRadioButton into my QWizardPage into my slot function?
Thanks