I am looking at how the qml viewer (for 4.8 and 5.0) is implemented. And I wonder why is it so.

In the .h(eader) we have:

Qt Code:
  1. class QtQuick2ApplicationViewer : public QQuickView
  2. {
  3. Q_OBJECT
  4.  
  5. ...
  6.  
  7. private:
  8. class QtQuick2ApplicationViewerPrivate *d;
  9. };
To copy to clipboard, switch view to plain text mode 

Then in the .CPP file:

Qt Code:
  1. class QtQuick2ApplicationViewerPrivate
  2. {
  3. QString mainQmlFile;
  4. friend class QtQuick2ApplicationViewer;
  5. static QString adjustPath(const QString &path);
  6. };
  7.  
  8. QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent)
  9. : QQuickView(parent)
  10. , d(new QtQuick2ApplicationViewerPrivate())
  11. {
  12. connect(engine(), SIGNAL(quit()), SLOT(close()));
  13. setResizeMode(QQuickView::SizeRootObjectToView);
  14.  
  15. #ifdef Q_OS_ANDROID
  16. engine()->setBaseUrl(QUrl::fromLocalFile("/"));
  17. #endif
  18. }
To copy to clipboard, switch view to plain text mode 

So I have basically two questions.
(1) The first one about the friend class. Why is it necessary. I don't see any reason why would anybody use a friend class. Is there any real use for friend classes (except for exotics that anybody could live without)?

(2) The second one is: connect(engine(), SIGNAL(quit()), SLOT(close())); Isn't quit() defined as slot? How is it a signal here? Is it wrong to use quit() instead of close()? connect(engine(), SIGNAL(quit()), SLOT(quit()));