Results 1 to 3 of 3

Thread: QTabBar setFocus

  1. #1
    Join Date
    May 2013
    Posts
    321
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default QTabBar setFocus

    Hi,
    I tried to use setFocus on a QMainWindow added in a tab of a QTabBar but I saw no effect on the call of this function.
    Is it normal ? Do I have to do a for loop to find the widget and set the current index on the tab bar ?
    Thanks

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: QTabBar setFocus

    A QTabBar does not have any content-containing panels. Did you perhaps mean a QTabWidget?

    Assuming that you expected calling widget->setFocus() to make the panel containing the widget visible then you really wanted QTabWidget::setCurrentWidget()
    If you actually have a QTabBar then the content is usually in a separate QStackedWidget, which has a similar function.
    Last edited by ChrisW67; 22nd March 2015 at 07:56.

  3. #3
    Join Date
    May 2013
    Posts
    321
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default Re: QTabBar setFocus

    Thanks that was that, now the for loop is not needed anymore, but the setFocus has to be set on the window containing the widget manually.
    I just asked if that's normal to have to do that manually, apparently you answered yes.
    After thinking about the problem, that's better to have to do it manually.

Similar Threads

  1. Replies: 0
    Last Post: 17th November 2011, 11:51
  2. Checkbox Setfocus
    By afro_cv in forum Qt Programming
    Replies: 2
    Last Post: 23rd August 2011, 14:09
  3. setFocus() on Lineedit
    By qtuser20 in forum Qt Programming
    Replies: 1
    Last Post: 26th February 2010, 18:54
  4. setFocus problem
    By roxton in forum Qt Programming
    Replies: 3
    Last Post: 12th February 2009, 05:41
  5. setfocus working?
    By mahe2310 in forum Qt Programming
    Replies: 8
    Last Post: 10th March 2006, 02: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.