Results 1 to 2 of 2

Thread: QDate class extension

  1. #1
    Join Date
    Oct 2007
    Location
    Warminster, England
    Posts
    31
    Thanks
    17
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question QDate class extension

    Is it possible to add new functions to the QDate class ?
    In particular, I wanted to add the functions monthsTo(Qdate adate) and yearsTo(QDate adate) to complement the existing daysTo(QDate adate) function.
    I know I could create a new class using QDate as a base, ie

    class myQDate : public QDate
    {
    // function prototypes
    int QDate::monthsTo(QDate adate);
    int QDate::yearsTo(QDate adate);
    };
    I would then need to change all my QDates to myQDates.
    Regarding future projects, is it better practice to create my own classes from the Qt bases if I suspect they may need to be extended.
    TIA
    Carlton.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDate class extension

    Instead of extending QDate you may implement standalone functions. Then you won't have to modify any code already written.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    Carlton (22nd February 2009)

Similar Threads

  1. QImage extension class
    By rbp in forum Qt Programming
    Replies: 2
    Last Post: 18th November 2008, 06:55
  2. Problems with QDate
    By cyberboy in forum Qt Programming
    Replies: 4
    Last Post: 25th May 2008, 21:17
  3. class QHBoxLayout
    By csvivek in forum Installation and Deployment
    Replies: 2
    Last Post: 10th April 2008, 07:57
  4. How to use Signal through direct connection
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2007, 07:07
  5. Client/Server Error: BadIDChoice
    By 3nc31 in forum Qt Programming
    Replies: 5
    Last Post: 27th November 2007, 10:22

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.