Hello,
How can one add multiple QComboBoxes using a for-loop?
Like we do in qcheckbox as:
Is there a similiar way to add multiple QComboBoxes aswell?
PS: i could not find the .arg() object in QComboBox :-(
Thanks!
Printable View
Hello,
How can one add multiple QComboBoxes using a for-loop?
Like we do in qcheckbox as:
Is there a similiar way to add multiple QComboBoxes aswell?
PS: i could not find the .arg() object in QComboBox :-(
Thanks!
arg() is a method of QString.
Okay, then what is the way of doing it for QComboBox?
I have a combobox next to checkbox. For checkbox I used the code as mentioned above.
Now I want to repeat this combination using a for-loop.
How can this be achieved?
@wysota
I have already tried this. But the comboBoxes are not repeated. Only the checkboxes are repeated. Following is my code:
Code:
for(k=0; k < 5 ; k++) { for(int i=0; i < 3; i++) { mComboBox1->addItem(tr("Item %2").arg(i)); } mComboBox1->setFixedWidth(200); ChannelLayout1->addWidget(mCheckBox1); ChannelLayout1->addWidget(mComboBox1,0,1,0,20); } GroupBox1->setLayout(ChannelLayout1);
Please help.
You are putting all comboboxes in one place in the layout.
@wysota
Ya, i figured that out. There was one more problem besides that in lines 15 and 16. The corrected lines are as follows:
Code:
15. ChannelLayout1->addWidget(mCheckBox1,k,0); 16. ChannelLayout1->addWidget(mComboBox1,k,1);
Thanks!
@wysota:
Thanks for ur advice. I have sorted it out! :-)
You are trying to set the same layout to two widgets.