Results 1 to 2 of 2

Thread: About inherit

  1. #1
    Join Date
    Jan 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default About inherit

    Hello everyone,


    I'm a newer for Qt, so pls forgiving the stupid question I asked,thanks in advance.
    here is the situation :
    I want to structure a class which need inherit from both class QFile and class QXmlStreamReader. then I did like this,
    Qt Code:
    1. #ifndef STREAMMANAGER_H
    2. #define STREAMMANAGER_H
    3.  
    4. #include <QFile>
    5. #include <QXmlStreamReader>
    6.  
    7. class StreamManager : public QFile ,public QXmlStreamReader
    8. {
    9. public:
    10.  
    11.  
    12. private:
    13.  
    14. };
    15. #endif STREAMMANAGER_H
    To copy to clipboard, switch view to plain text mode 

    but now in main.cpp, I want open a xml file, I just don't know how to do that, as usuall, I will use QFile Object, something like "QFile *file = new QFile("/ex/ex.xml");"
    , but ,how can I do now?
    Qt Code:
    1. ....
    2. ....
    3. int main(int argc, char *argv[])
    4. {
    5. StreamManager *mym = new StreamManager();
    6. return app.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 

    one more thing, class StreamManager is a inherited class, and I found I can't create it's own initialized function,what wrong?

    Many thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: About inherit

    I want to structure a class which need inherit from both class QFile and class QXmlStreamReader.
    You don't need multiple inheritance here.
    QXmlStreamReader takes a QIODevice as parameter.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Inherit from QTabWidget
    By Suncell in forum Newbie
    Replies: 2
    Last Post: 27th June 2010, 21:06
  2. How to use the ui_*.h,inherit it or as a member?
    By 75543255 in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2009, 10:45
  3. Inherit the QAxWidget
    By MrShahi in forum Qt Programming
    Replies: 3
    Last Post: 29th April 2008, 08:06
  4. How to inherit correct canReadLine()
    By The Storm in forum Qt Programming
    Replies: 7
    Last Post: 25th March 2008, 09:33
  5. Object Inherit from QTreeWidgetItem
    By xgoan in forum Qt Programming
    Replies: 6
    Last Post: 18th August 2006, 12:20

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.