Results 1 to 4 of 4

Thread: Managing widget focus behaviour

  1. #1
    Join Date
    Mar 2007
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Managing widget focus behaviour

    I'm using Qt 4.3.3 on Xcode. I need to know a way to prevent a parent widget to keep on showing & focusing itself, when a child widget is closed.

    Example:

    I have one QWidget, and 2 QDialog as a child of QWidget.
    In some cases a user could open one of the QDialog (let's call it dialogOne), and when dialogOne is showed, a user open dialogTwo.

    Based on what I have been coded, the last shown dialog takes top position (the window is activated). But when I close the top dialog (either dialogOne or dialogTwo), the focus is moved to the main QWidget (the parent).

    Now, what I want to do is to make a focus behaviour based on least recently focused widget / dialog. So for example:

    If the order of widget is (bottom to top in Z-axis): parentWidget->dialogOne->dialogTwo.

    When I close dialogTwo, the order is:
    parentWidget->dialogOne.

    If the order of widget is (bottom to top in Z-axis): parentWidget->dialogTwo->dialogOne.

    When I close dialogTwo, the order is:
    parentWidget->dialogTwo.

    Is there anyone that could help me on this issue ?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Managing widget focus behaviour

    Well, that's the natural an expected behavior. You can
    Qt Code:
    1. dialogOne->raise();
    2. dialogOne->activateWindow();
    To copy to clipboard, switch view to plain text mode 
    yourself if you want to behave it differently.
    J-P Nurmi

  3. #3
    Join Date
    Mar 2007
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Managing widget focus behaviour

    I don't think it's a natural behavior from the point of view of user on Mac OS X.
    If I observe other apps (probably using Cocoa), the closing of one window doesn't activate the main window, but it activates the most recent focused window.

    Well, the problem with your suggestion is I need to do that manual activation on all dialogs.

    Should I do something in another way ?
    Like not making dialogOne & dialogTwo a child of the QWidget ?

    Which is the best parent for all widgets ?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Managing widget focus behaviour

    You should wait for 4.4. As far as I know (I might be wrong though) it respects the focus order on Mac. You might try one of the snapshots and see if it works. If it doesn't then it means the observed behaviour is expected. Make sure you are using modal dialogs and the parent-child relationship is correct.

Similar Threads

  1. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  2. Force focus to a QTabWidget page's widget
    By thomaspu in forum Qt Programming
    Replies: 1
    Last Post: 2nd January 2008, 06:54
  3. How to get focus event in child widget
    By YuriyRusinov in forum Qt Programming
    Replies: 4
    Last Post: 17th October 2006, 07:53
  4. Managing widget plugin in Qt Designer
    By yellowmat in forum Newbie
    Replies: 8
    Last Post: 31st January 2006, 09:58

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.