Results 1 to 2 of 2

Thread: An extremely noob question about QtQuick viewer implementation???

  1. #1
    Join Date
    Mar 2011
    Posts
    29
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question An extremely noob question about QtQuick viewer implementation???

    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()));

  2. #2
    Join Date
    Nov 2010
    Posts
    82
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: An extremely noob question about QtQuick viewer implementation???

    1 - i can't really answer this but this implementation is done in all QT class i think.

    2 - the quit signal is from the engine not the viewer, so if the engine says i m off the view cannot do much and has to quit to avoid problems

Similar Threads

  1. MultiLinguage implementation in QTQuick.
    By satya@sipl in forum Newbie
    Replies: 1
    Last Post: 6th August 2012, 07:31
  2. How to get Text value of a QDomElement ? (noob question)
    By BillGates in forum Qt Programming
    Replies: 6
    Last Post: 31st August 2010, 14:01
  3. QWizard noob question
    By Ossi in forum Newbie
    Replies: 5
    Last Post: 2nd September 2009, 12:30
  4. a simple noob question
    By wrproject in forum Newbie
    Replies: 1
    Last Post: 1st July 2008, 23:25
  5. OpenGL image viewer, need some help on implementation
    By Randulf in forum General Programming
    Replies: 11
    Last Post: 11th May 2007, 14:58

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.