1 Attachment(s)
Multible QCombobox tree with model view
Hi
I have a simple tree that i want to present in QCombobox:
A
-a
-b
-c
B
-e
-f
C
Attachment 5150
When selecting A in the first combobox, I want to populate the children A (a, b, c) in the second combox. I have used the qt example simpletreemodel. I tryed to fidle with the QDataWidgetMapper without anny success. What is the right way too go here (qt way)?
Anny good ideas?
Re: Multible QCombobox tree with model view
QComboBox::setModel(your model)
QComboBox::setRootModelIndex(index of the first combobox)
Re: Multible QCombobox tree with model view
thanks...
void ComboBoxTreeView::updateRootModelIndex()
{
if(m_model == 0)
return;
int size = m_group->count();
for(int i = 0; i < size;i++)
{
QComboBox* box = m_group->getComboBox(i);
if(i > 0)
{
QComboBox *parent = m_group->getComboBox(i-1);
if(parent->isWidgetType())
{
QModelIndex pindex = parent->rootModelIndex();
box->setRootModelIndex(pindex.child(parent->currentIndex(),0));
}
}
else if(i == 0)
{
box->setRootModelIndex(m_model->index(0,0));
}
}
}