Results 1 to 17 of 17

Thread: How to move QMdiSubWindow in and out of QMdiArea?

  1. #1
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to move QMdiSubWindow in and out of QMdiArea?

    Hi,

    I try to implement QMdiSubWindow::moveEvent so that user can grab QMdiSubWindow and move it in and out of QMdiArea, much the same way as Google's chrome does.

    However can I achieve that while QMdiArea::subWindowList still keeps the list even though the QMdiSubWindow is moved out?

    Thanks

  2. #2
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Программы для windows 7

    Anyone please?

  3. #3
    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: How to move QMdiSubWindow in and out of QMdiArea?

    It is possible to detach the window by writing some code but the window will become a standalone window, it will not be in the list of mdi subwindows. You need to keep your own list of windows that includes both those attached to the mdi and those you have detached. I implemented something like that but it doesn't work by moving the window. Rather than that I have a button or keyboard shortcut for that. With chrome it is easy because to detach a window, you grab and pull its tab. With MDI you don't have such tabs (unless you're working in document mode).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    May 2009
    Posts
    52
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to move QMdiSubWindow in and out of QMdiArea?

    I think Google Chrome is different, every tab is a separate process if I'm not mistaken

  5. #5
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to move QMdiSubWindow in and out of QMdiArea?

    It appears to be easy but rather it is not.

    I re-implement QMdiSubWindow::moveEvent ( QMoveEvent * event ), I did QMdiArea::removeSubWindow or QMdiArea::addSubWindow based on mouse inside or outside the QMdiArea. Then re-implement QMdiArea::childEvent to manage my own subwindow list, with subwindow's destroyed signal attached, it still won't work...

    Without tab you can grab subwindow's title bar, so that is not an issue though...

  6. #6
    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: How to move QMdiSubWindow in and out of QMdiArea?

    Quote Originally Posted by lni View Post
    it still won't work...
    What doesn't work?

    Without tab you can grab subwindow's title bar, so that is not an issue though...
    The problem is not having anything to grab or not, it is detecting when to detach.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to move QMdiSubWindow in and out of QMdiArea?

    Quote Originally Posted by wysota View Post
    What doesn't work?


    The problem is not having anything to grab or not, it is detecting when to detach.
    Please look at the attached codes and see if we can get something going together.
    Attached Files Attached Files

  8. #8
    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: How to move QMdiSubWindow in and out of QMdiArea?

    So what doesn't work?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to move QMdiSubWindow in and out of QMdiArea?

    Quote Originally Posted by wysota View Post
    So what doesn't work?
    Can't get QMdiSubWindow::focusInEvent after it is moved out. So I can't get signal QMdiArea::subWindowActivated ( QMdiSubWindow * )...

    Any idea?

  10. #10
    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: How to move QMdiSubWindow in and out of QMdiArea?

    You won't get that event because there is no subwindow for the detached window.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to move QMdiSubWindow in and out of QMdiArea?

    Quote Originally Posted by wysota View Post
    You won't get that event because there is no subwindow for the detached window.
    I understand I won't get QMdiArea::subWindowActivated ( QMdiSubWindow * ) signal, but I should get QMdiSubWindow::focusInEvent because it belongs to QWidget?

  12. #12
    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: How to move QMdiSubWindow in and out of QMdiArea?

    Your widget is not a subclass of QMdiSubWindow. You will get a focusIn event for the widget itself, provided that the widget itself accepts focus.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to move QMdiSubWindow in and out of QMdiArea?

    Quote Originally Posted by wysota View Post
    Your widget is not a subclass of QMdiSubWindow. You will get a focusIn event for the widget itself, provided that the widget itself accepts focus.
    OK, it got too many problems, such as when I call QMdiArea::tileSubWindows or QMdiArea::cascadeSubWindows, the QMdiSubWindow::moveEvent got called and all the subwindows are detached from the QMdiArea.

    So I decide to override QMdiSubWindow's system menu by adding "Detach from Work Area" and "Attach to Work Area". The "Detach from Work Area" is added correctly to the QMdiSubWindow's system menu. However, after it is detached, the window becomes a standalone window and the window manager's system menu is used. I lose those menu items that I have added...

    Is there a way to solve this?

  14. #14
    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: How to move QMdiSubWindow in and out of QMdiArea?

    Quote Originally Posted by lni View Post
    Is there a way to solve this?
    The way I did it is that I wrapped every detachable widget in another object (call it Window or sth like that) that has an interface similar to QWidget and whenever I want to do something on my widget, I call it through this interface. This gives me a wrapper both when the window is in the MDI area (a.k.a. has a QMdiSubWindow instance) or not. Then I can assign a keyboard shortcut or a context menu handler to all widgets I want and attach the window from there.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #15
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to move QMdiSubWindow in and out of QMdiArea?

    Quote Originally Posted by wysota View Post
    The way I did it is that I wrapped every detachable widget in another object (call it Window or sth like that) that has an interface similar to QWidget and whenever I want to do something on my widget, I call it through this interface. This gives me a wrapper both when the window is in the MDI area (a.k.a. has a QMdiSubWindow instance) or not. Then I can assign a keyboard shortcut or a context menu handler to all widgets I want and attach the window from there.
    Could you show the codes? Thanks

  16. #16
    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: How to move QMdiSubWindow in and out of QMdiArea?

    Quote Originally Posted by lni View Post
    Could you show the codes? Thanks
    Unfortunately no, it's not open source.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  17. #17
    Join Date
    May 2013
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to move QMdiSubWindow in and out of QMdiArea?

    this is what I did from the main window to pop out a window.
    Qt Code:
    1. void MainWindow::on_action_Pop_Out_triggered()
    2. {
    3. if (ui->mdiArea->activeSubWindow()){
    4. QMdiSubWindow *sub = ui->mdiArea->activeSubWindow();
    5. QWidget *wid = sub->widget();
    6. wid->hide();
    7. sub->deleteLater();
    8. ui->mdiArea->removeSubWindow(wid);
    9. wid->show();
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 1
    Last Post: 28th June 2012, 14:29
  2. Wish to have a QMdiSubWindow window larger than the QMdiArea
    By zenzero-2001 in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2010, 17:44
  3. Problem in Move Move Event Handler.
    By redgoof in forum Qt Programming
    Replies: 0
    Last Post: 7th April 2010, 11:45
  4. Moving a QMdiSubWindow
    By philwinder in forum Qt Programming
    Replies: 1
    Last Post: 2nd November 2008, 10:12
  5. Move Rectangle on mouse Move
    By vermarajeev in forum Qt Programming
    Replies: 24
    Last Post: 14th May 2007, 05:34

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.