Results 1 to 2 of 2

Thread: Bug with QMdiSubWindow Close window flag, or am I doing this wrong?

  1. #1
    Join Date
    Oct 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Bug with QMdiSubWindow Close window flag, or am I doing this wrong?

    Summary: I have a MainWindow with an MDI area within which I want to place subwindows (QWidgets). I would like these subwindows to have a Minimize and a Close button, i.e. no Maximize button. My problem is that I can't get the Close button to show up no matter what I do. It's like the flag is ignored on MDI subwindows.

    First, I realized that doing myqwidget->setWindowFlags(myflags) did not do anything anymore. Regardless of what flags I specify, they are ignored and "default" flags are used. The MDI area requires you to set flags on the QMdiSubWindow, not the QWidget it represents.

    No biggie, because I just used
    Qt Code:
    1. QMdiSubWindow *sub = ui->mdiArea->addSubWindow(myqwidget);
    2. sub->setWindowsFlags(myflags);
    To copy to clipboard, switch view to plain text mode 

    The above does set flags, EXCEPT for the Close flag. In other words when I do this:
    Qt Code:
    1. Qt::WindowFlags flags;
    2. flags |= Qt::WindowCloseButtonHint;
    3. flags |= Qt::WindowMinimizeButtonHint;
    4. sub->setWindowFlags(flags);
    To copy to clipboard, switch view to plain text mode 

    Only the Minimize button appears. I have tried every flag variation I could think of (including only using CloseButton), to no avail. In a non-MDI window, the CloseButtonHint of course works fine.

    I'm not sure if this is a bug I should report or intended behaviour. I spent 2 hours reading the doc and I couldn't find any mention of special Close flag behavior for MDI subwindows. I figured I'd ask here to get confirmation before I bother the Qt team with a bug report. What do you guys think?

    I've attached a basic project that demonstrates this. All the code is in MainWindow's constructor.
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Bug with QMdiSubWindow Close window flag, or am I doing this wrong?

    From the docs:
    Adds a close button. On some platforms this implies Qt::WindowSystemMenuHint for it to work.
    On Linux the following works:
    Qt Code:
    1. subwindow->setWindowFlags(Qt::WindowMinimizeButtonHint| Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Close event in QMdiSubWindow
    By bxaHj in forum Newbie
    Replies: 1
    Last Post: 26th May 2009, 21:18
  2. Window Flag
    By zgulser in forum Qt Tools
    Replies: 1
    Last Post: 9th January 2009, 14:24
  3. QMdiSubWindow closes main window
    By frido in forum Qt Programming
    Replies: 1
    Last Post: 25th July 2008, 10:54
  4. Close a QMdiSubwindow
    By John_P in forum Qt Programming
    Replies: 4
    Last Post: 14th March 2008, 17:23
  5. Changing AlwaysOnTop window flag
    By bpetty in forum Newbie
    Replies: 5
    Last Post: 19th February 2007, 23:45

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.