I'm having problems with this simple program:

Qt Code:
  1. #include <QApplication>
  2. #include <QLabel>
  3.  
  4. int main( int argc, char **argv )
  5. {
  6. QApplication app( argc, argv );
  7.  
  8. QLabel *lab = new QLabel("Very important Main Window");
  9. lab->setAttribute(Qt::WA_QuitOnClose, true);
  10. lab->show();
  11.  
  12. QLabel *lab2 = new QLabel("less important auxilliary window");
  13. lab2->setAttribute(Qt::WA_QuitOnClose, false);
  14. lab2->show();
  15.  
  16. app.setQuitOnLastWindowClosed(true);
  17.  
  18. return app.exec();
  19. }
To copy to clipboard, switch view to plain text mode 

The idea is that there are two windows. One important and one less important. The application is supposed to quit when the last "important" window is closed.
When run in Qt4, the program behaves the way I want it to: when I close the "important" window the app quits regardless of whether the less important windows was alive then.

In Qt5 things go differently:

1. close less important window
2. close important window
3. --> app exits : OK

1. close important window
2. (app doesn't exit)
3. close less important window
4. (app still doesn't exit)

The documentation for WA_QuitOnClose and setQuitOnLastWindowClosed() seems to be unchanged between Qt4 and Qt5.
So is there a bug in Qt5 or have I misunderstood these attributes?