Results 1 to 2 of 2

Thread: How to keep a floating dock visible?

  1. #1
    Join Date
    Jan 2006
    Location
    Genk, Belgium
    Posts
    36
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanked 1 Time in 1 Post

    Default How to keep a floating dock visible?

    I have an application with multiple toplevel windows besides the main window.
    I have floating docks.
    These docks disappear when I activate a secondary window. They are only shown when the main window has focus.
    (How) can I change this behavior, keeping the docks visible whenever any application window has focus?

    Qt Code:
    1. #include <QMainWindow>
    2. #include <QDockWidget>
    3. #include <QApplication>
    4.  
    5. int main(int argc, char ** argv )
    6. {
    7. QApplication a( argc, argv );
    8. QMainWindow* mw = new QMainWindow();
    9. mw->setWindowTitle("The main window");
    10.  
    11. QDockWidget* dock = new QDockWidget(mw);
    12. dock->setFloating(true);
    13. dock->setWindowTitle("The disappearing dock");
    14. dock->show();
    15.  
    16. QWidget* w = new QWidget(mw);
    17. w->setWindowTitle("The second window");
    18. w->setWindowFlags(Qt::Window);
    19. w->setVisible(true);
    20.  
    21. mw->show();
    22. return a.exec();
    23. }
    To copy to clipboard, switch view to plain text mode 

    Reproduction:
    - place the attached source file in a directory.
    - execute qmake -project; qmake;make
    - execute the application
    - click on "The second window"
    Now the dock has disappeared...
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: How to keep a floating dock visible?

    You will have to subclass QWindow and set the appropriate window flags to make it look like a dock (see QtDemo sample for this) and also set the always on top flag.

    When you create them, make sure you do not set them any parent.

    This should work just fine.

Similar Threads

  1. Mac application and the Dock Icon
    By sekelsenmat in forum Qt Programming
    Replies: 3
    Last Post: 26th September 2007, 11:23

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.