SetFocus on widget in a new



  • 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.



  • @QWidget obj = (QWidget)m_formCategories->children().at(0);
    obj->setFocus();@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.