Results 1 to 5 of 5

Thread: Focus and interact with a QDockWidget and the MainWindow separately.

  1. #1

    Default Focus and interact with a QDockWidget and the MainWindow separately.

    I have created an application which consists of one MainWindow (containing a text-editor) and optional additional windows (QWidgets, containing additional text-editors).

    The MainWindow is provided with a Dock which lists the available documents opened within the project, and highlights in the list the document currently selected.

    The only problem is that when I focus an additional window and I then click on the floating dock, the MainWindow gets focused. I would like therefore to be able to focus a floating dock separately, but I have no idea on how to separate the focus of the main window from the focus of the dockWidget.

    Also, I guess that when I click on a Dock, the application reacts as if I clicked the MainWindow. I would like then the MainWindow to be unawared whether the Dock is clicked or not (when the dock is undocked).

    Does somebody have any idea?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Focus and interact with a QDockWidget and the MainWindow separately.

    I am not sure I fully understand what you are looking for, but are you currently somehow tracking focus to determine which document is selected?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Focus and interact with a QDockWidget and the MainWindow separately.

    I would like therefore to be able to focus a floating dock separately, but I have no idea on how to separate the focus of the main window from the focus of the dockWidget.
    Perhaps you don't understand what "focus" means. In a windowing system, for a window to have the "focus" means that all user interaction goes to that window for handling - like keystrokes, mouse clicks, etc. If two windows simultaneously could have the focus, it would mean that any typing or mouse clicks you did would go to both of the windows at the same time. That would make no sense at all. Only one window can have the input focus at any time.

    So what is it you really want to do? Somehow indicate to the user which document is the active document even if that document's window does not have the input focus?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  4. #4

    Default Re: Focus and interact with a QDockWidget and the MainWindow separately.

    I see.
    I am sorry.
    What I would like is to click on a floating QDockWidget without having the all MainWindow to come up in front (covering other visible Widgets).

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Focus and interact with a QDockWidget and the MainWindow separately.

    I don't understand your UI. Do you mean to say that you have a MainWindow with dock widgets, menu., toolbars, etc. and you also have a set of independent top-level windows floating on screen at the same time?

    Maybe you can try to pass the Qt::WindowStaysOnTopHint to QWidget::setWindowFlags(), but I do not know if you can change this dynamically (in other words, set and unset the flag for a particular widget on the fly).

    Another option would be to use QMdiArea as the central widget of your MainWindow and add all of your document windows to that as children. Then, your main window would always be below your document windows.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. get notified when QDockWidget gets/looses focus?
    By tuli in forum Qt Programming
    Replies: 1
    Last Post: 17th December 2012, 17:42
  2. How to set focus (select) a tabbed QDockWidget?
    By serget in forum Qt Programming
    Replies: 4
    Last Post: 14th March 2012, 17:40
  3. Focus in QDockWidget disappears
    By Debilski in forum Qt Programming
    Replies: 3
    Last Post: 30th March 2011, 13:40
  4. Mainwindow layout problem with QDockWidget.
    By pastispast in forum Qt Programming
    Replies: 3
    Last Post: 13th January 2011, 07:04
  5. Focus on QDockWidget
    By lynnH in forum Qt Programming
    Replies: 0
    Last Post: 20th April 2010, 12:23

Tags for this Thread

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.