Results 1 to 7 of 7

Thread: Subclassing QDateEdit

  1. #1
    Join Date
    Jan 2006
    Location
    11 N 78 E
    Posts
    110
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Subclassing QDateEdit

    I would like to subclass QDateEdit to display the dates of a different calendar. Because of this, I would like to reimplement virtual functions of that class (which is nothing but a special case of QDateTimeEdit) which validate the date, as the valid and invalid dates have different rules in this other calendar. I looked through qt-x11-opensource-src-4.1.0/src/gui/widgets/qdatetimeedit.cpp and found the validateAndInterpret() function. This seems to refer to a parse() function but where is this parse function? Can anyone help?
    Penguin #395953 using Qt for open-source development on X11 using C++ and
    Python via PyQt

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Subclassing QDateEdit

    Did you try looking in src/corelib/tools/qdatetime.cpp?

  3. #3
    Join Date
    Jan 2006
    Location
    11 N 78 E
    Posts
    110
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Subclassing QDateEdit

    Cool. src/gui/widgets/qdatetimeedit.h calls include/QtCore/qdatetime.h which calls src/corelib/tools/qdatetime.h. Now I see all I need to modify is at src/corelib/tools/qdatetime.cpp, but can I accomplish my goal by just subclassing mycalendardate under qdate and reimplementing the functions from qdatetime.cpp which I have to change?
    Penguin #395953 using Qt for open-source development on X11 using C++ and
    Python via PyQt

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Subclassing QDateEdit

    IMO subclassing won't help you much as you won't have access to a lot of methods that implement the functionality you want to change. Maybe you should consider creating a separate widget based upon modified QDateTimeEdit code?

  5. #5
    Join Date
    Jan 2006
    Location
    11 N 78 E
    Posts
    110
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Subclassing QDateEdit

    Quote Originally Posted by jacek
    IMO subclassing won't help you much as you won't have access to a lot of methods that implement the functionality you want to change. Maybe you should consider creating a separate widget based upon modified QDateTimeEdit code?
    Pardon, but which methods do you refer to? I thought subclassing will allow me to access all the functions defined for a particular class, replacing those that I redefine with my own.
    Penguin #395953 using Qt for open-source development on X11 using C++ and
    Python via PyQt

  6. #6
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Subclassing QDateEdit

    Quote Originally Posted by jamadagni
    Pardon, but which methods do you refer to? I thought subclassing will allow me to access all the functions defined for a particular class, replacing those that I redefine with my own.
    Not all just the virtual ones

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Subclassing QDateEdit

    Quote Originally Posted by yop
    Not all just the virtual ones
    ... that are public or protected. All private methods and member variables won't be accessible.

Similar Threads

  1. How to put empty value in QDateEdit?
    By sawerset in forum Qt Programming
    Replies: 5
    Last Post: 14th October 2019, 22:06
  2. QDateEdit emiting signal problem
    By anafor2004 in forum Newbie
    Replies: 1
    Last Post: 17th June 2008, 08:59
  3. QTableWidget + QDateEdit + Delegates
    By Cykus in forum Newbie
    Replies: 1
    Last Post: 8th June 2008, 01:43
  4. Clearing QDateEdit
    By jpujolf in forum Qt Programming
    Replies: 3
    Last Post: 27th July 2006, 22:19
  5. Problem with receiving events from QDateEdit
    By gunhelstr in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2006, 12:21

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.