Results 1 to 3 of 3

Thread: SetFocus on tabwidget item

  1. #1
    Join Date
    Oct 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default SetFocus on tabwidget item

    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:

    Qt Code:
    1. void MainWindow::openFormCateries()
    2. {
    3. if(m_formCategories == 0)
    4. {
    5. m_formCategories = new FormCategories(this);
    6. ui->tabWidget->addTab(m_formCategories, tr("Categories"));
    7.  
    8. }
    9. ui->tabWidget->setCurrentWidget (m_formCategories);
    10. }
    To copy to clipboard, switch view to plain text mode 

    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.

  2. #2
    Join Date
    Feb 2011
    Location
    The Netherlands
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SetFocus on tabwidget item

    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

  3. #3
    Join Date
    Feb 2011
    Location
    The Netherlands
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SetFocus on tabwidget item

    Hi Alex,

    I suppose that you create the tab dynamically?

    If so this thread will may help you.
    http://www.qtcentre.org/threads/4536...ed-dynamically

    Fabian

Similar Threads

  1. Replies: 11
    Last Post: 30th August 2011, 09:10
  2. Checkbox Setfocus
    By afro_cv in forum Qt Programming
    Replies: 2
    Last Post: 23rd August 2011, 15:09
  3. setFocus() on Lineedit
    By qtuser20 in forum Qt Programming
    Replies: 1
    Last Post: 26th February 2010, 19:54
  4. QLineEdit setFocus
    By bunjee in forum Qt Programming
    Replies: 4
    Last Post: 24th April 2008, 17:22
  5. setfocus working?
    By mahe2310 in forum Qt Programming
    Replies: 8
    Last Post: 10th March 2006, 03:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.