PDA

View Full Version : SetFocus on tabwidget item



abibiano
26th October 2011, 07:21
I have a main window with a QListWidget as menu and a QTabWidget as my main area.

When I click on a menu item on the listwidget I create my form and add it to the tabwidget.

This is the code used:


void MainWindow::openFormCateries()
{
if(m_formCategories == 0)
{
m_formCategories = new FormCategories(this);
ui->tabWidget->addTab(m_formCategories, tr("Categories"));

}
ui->tabWidget->setCurrentWidget (m_formCategories);
}

My problem is that I don’t know how to set the focus on the first editable item from the new created form added to the tab.

I have for example a QLineEdit in m_formCategories and want to set it as the active control.

I have tried set the focus on the constructor from m_formCategories whith ui->lineedit1->setfocus() but it dosen’t work.

Thanks,

Alex B.

grove
26th October 2011, 18:40
Hi Alex,

I've the same problem with only with editing the values that are on that tab.

A lot of searching didn't brought me any solution.

So far is I know there is no solution for this problem.
I've made a different dialog for editing the values.

Please let me know if you find a solution for it.

Fabian

grove
27th October 2011, 12:29
Hi Alex,

I suppose that you create the tab dynamically?

If so this thread will may help you.
http://www.qtcentre.org/threads/45361-how-to-get-lineEdit-content-which-is-created-dynamically

Fabian