Results 1 to 5 of 5

Thread: Subclass QList<T>

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Subclass QList<T>

    Quote Originally Posted by Seishin View Post
    I want to make a subclass of QList for any type T.
    QList already is list of arbitrary type T. It already is a template class.

  2. #2
    Join Date
    Jul 2012
    Posts
    53
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    16
    Thanked 1 Time in 1 Post

    Default Re: Subclass QList<T>

    Quote Originally Posted by ChrisW67 View Post
    QList already is list of arbitrary type T. It already is a template class.
    You are right. But I want to override some function of QList later, so I try to make a simple copy subclass first.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Subclass QList<T>

    QList is not designed to be inherited and have its behaviours overridden: it has no virtual functions. Its destructor is not virtual so polymorphic pointers (if you were intending to use them) will also be dangerous. You could add behaviours like QStringList does.

    You usually better off either using QList<T> as-is or incorporating it by composition rather than inheritance.

Similar Threads

  1. Replies: 2
    Last Post: 15th April 2013, 06:33
  2. Qlist<QLabel *> in Qlist<QAction*>
    By Naahmi in forum Qt Programming
    Replies: 1
    Last Post: 9th September 2011, 08:53
  3. QObject subclass in a QList
    By plan_rich in forum Newbie
    Replies: 3
    Last Post: 21st September 2010, 15:51
  4. Replies: 4
    Last Post: 20th August 2010, 13:54
  5. Replies: 8
    Last Post: 12th February 2010, 02:41

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
  •  
Qt is a trademark of The Qt Company.