Results 1 to 7 of 7

Thread: [SOLVED] Qt 4.7.2 - QTabWidget - Give the focus to QTabWidget's current widget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default [SOLVED] Qt 4.7.2 - QTabWidget - Give the focus to QTabWidget's current widget

    Hi, my application has a QTabWidget object and each tab consists of an editor. What I would like is that if my QTabWidget object gets the focus, then the editor of the current tab should automatically get the focus.

    I have been able to get this to work to an extent (e.g. when switching from one tab to another), but when another widget in my application has the focus and that I then click on the active tab of my QTabWidget object, the editor for that tab doesn't get the focus. I need to switch to another tab and back to get the focus which is clearly not what I want. On the other hand, if another widget in my application has the focus and that I then click on a non-active tab in my QTabWidget object, then the editor for that tab gets the focus, as expected since I take advantage of the QTabWidget::currentChanged signal to give the focus to the editor for the active tab.

    I have looked into overriding the QTabWidget::focusInEvent, but to no avail. I also thought I might get it to work by using QTabWidget::setFocusProxy, but still to no avail. Otherwise, yes, I do have given a strong focus policy to my QTabWidget object, since I want my QTabWidget object to accept focus by both tabbing and clicking (and tabbing works perfectly fine indeed).

    So... any idea of how I could achieve what I am after?...
    Last edited by agarny; 8th April 2011 at 11:07.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt 4.7.2 - QTabWidget - Give the focus to QTabWidget's current widget

    I have looked into overriding the QTabWidget::focusInEvent, but to no avail.
    Can you show the code and tell what is the behavior observed?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. QTabWidget Corner Widget Problem
    By isamert in forum Qt Programming
    Replies: 6
    Last Post: 12th February 2011, 15:46
  2. Add multiple widget to QTabWidget Tab
    By Rooster in forum Newbie
    Replies: 5
    Last Post: 28th October 2010, 22:07
  3. How to add close button to each tab widget Qtabwidget?
    By kishore7771 in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2010, 08:42
  4. QTabWidget: how to force "no current widget"?
    By mattc in forum Qt Programming
    Replies: 4
    Last Post: 13th May 2009, 12:18
  5. Force focus to a QTabWidget page's widget
    By thomaspu in forum Qt Programming
    Replies: 1
    Last Post: 2nd January 2008, 06:54

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.