PDA

View Full Version : setting tab order for custom widgets not working



wagmare
15th December 2015, 12:17
hi friends/Experts,
Im trying to set the tab order for the Custom widget im adding on the widget created by designer.

I used scrollArea and a line edit . so when the user enter 10, 10 custom widgets will be added to the scroll area.

I set the scrollArea tab no as ex:5 and 6,7 and 8 to the ok , cancel, clear push buttons.

when the text entered in the edit
entries = LineEdit entry.


while(entries)
{
SpeciesInfo *SpeciesParent = new SpeciesInfo(this);

m_speciesList<<SpeciesParent;

scrollLayout->addWidget(SpeciesParent); //Entries added to scrollarea layout


entries --;
}



ui.speciesScrollArea->setFocusProxy(m_speciesList.at(0));
ui.speciesScrollArea->setFocusPolicy(Qt::TabFocus);

but the taborder is coming to speciesInFo only after ok,cancel and clear button. tab order is not coming inside the speciesInfo when it reach the tab on ScrollArea.

addition information:

scrollLayout = new QVBoxLayout;
scrollWidget->setLayout(scrollLayout);
ui.speciesScrollArea->setWidget(scrollWidget);
ui.speciesScrollArea->setContentsMargins(0,0,0,0);
ui.speciesScrollArea->viewport()->setAutoFillBackground(true);

inside SpeciesInfo policy setFocusPolicy(Qt::TabFocus);

please help me. thanks in advance11574

d_stranz
15th December 2015, 17:56
I don't see that you are setting tab order at all. You set the focus policy and focus proxy for one of your widgets, but that says nothing about tab order.

Look at the static method QWidget::setTabOrder().

wagmare
16th December 2015, 05:56
thanks for reply d_stanz. the scrollArea tabOrder is set to say 8. so when the eighth tab comes the focus has to enter into the custom widget but it is not doing so. the custom widget receives the tab focus only after ok,clear and cancel button tab focus which is 10, 11 and 12th index.

d_stranz
16th December 2015, 15:42
Are you calling QWidget::setTabOrder() on your newly-created widgets? If not, I am pretty sure they will be added to the tab order after any existing widgets.