Results 1 to 6 of 6

Thread: Floating windows constrained to within the MainWindow?

  1. #1
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    17
    Thanked 7 Times in 4 Posts

    Question Floating windows constrained to within the MainWindow?

    I would like to create an application where I can have frames/windows inside of a main window that the users would be allowed to resize and move as they wish but would be constrained to the main window. Java Swing has the concept of a JDesktopPane that does that. I looked at QDockWidget but those widgets are allowed to move outside of the main window.

    Is there any way currently to do this without making my own? This would have to be able to run under the commercial license.

    Thanks,
    Nisha

  2. #2
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 21 Times in 21 Posts

    Default Re: Floating windows constrained to within the MainWindow?

    You can use QDockWidget, it seems to be the easiest solution

    By the way, you can prevent docked widgets from floating outside of the mainwindow :

    Qt Code:
    1. dockwidget->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable)
    To copy to clipboard, switch view to plain text mode 

    Just omit the feature
    Qt Code:
    1. QDockWidget::DockWidgetFloatable
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to guilugi for this useful post:

    fnmblot (10th July 2007)

  4. #3
    Join Date
    Sep 2006
    Posts
    46
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2
    Thanked 3 Times in 2 Posts

    Default Re: Floating windows constrained to within the MainWindow?


  5. #4
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    17
    Thanked 7 Times in 4 Posts

    Default Re: Floating windows constrained to within the MainWindow?

    guilugi:

    Thanks. I tried it but I cannot move the window around or resize it. I did the following in my main.cpp. (I added the test widget which is just a simple wrapper around a QGLWidget to give the window a body. Even without it, it didn't work):

    Qt Code:
    1. QDockWidget *dockWidget;
    2. dockWidget = new QDockWidget(ui.frame);
    3. dockWidget->setGeometry(QRect(40, 30, 120, 80));
    4. dockWidget->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable);
    5.  
    6. GLTestWidget *glWidget = new GLTestWidget();
    7. dockWidget->setWidget(glWidget);
    To copy to clipboard, switch view to plain text mode 

    merlvingian:

    Thanks for the reference to QWorkspace. I'm looking at it now but I am not sure I understand the relationship between it and QMdiXXX widgets

    -- Nisha

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

    Default Re: Floating windows constrained to within the MainWindow?

    Quote Originally Posted by ntp View Post
    I am not sure I understand the relationship between it and QMdiXXX widgets
    QMdiXXX is a replacement for QWorkspace in Qt 4.3.
    J-P Nurmi

  7. #6
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    17
    Thanked 7 Times in 4 Posts

    Default Re: Floating windows constrained to within the MainWindow?

    QMdiArea looks like it has what I need. I assume that once I get into it, I'll be able to have some control over the subwindow's menus for maximize, minimize, etc.

    It was as simple as this:

    Qt Code:
    1. QMdiArea* mdiArea = new QMdiArea(ui.frame);
    2. GLTestWidget *glWidget = new GLTestWidget();
    3. mdiArea->addSubWindow(glWidget);
    To copy to clipboard, switch view to plain text mode 

    Thanks everyone!

    Nisha

Similar Threads

  1. Floating MainWindow on OS X
    By dvmorris in forum Qt Programming
    Replies: 7
    Last Post: 14th May 2007, 10:11

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.