PDA

View Full Version : Subclassing QDateEdit



jamadagni
2nd February 2006, 18:03
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?

jacek
2nd February 2006, 18:32
Did you try looking in src/corelib/tools/qdatetime.cpp?

jamadagni
3rd February 2006, 11:29
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?

jacek
3rd February 2006, 11:40
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?

jamadagni
4th February 2006, 07:33
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.

yop
4th February 2006, 10:20
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

jacek
4th February 2006, 14:26
Not all just the virtual ones
... that are public or protected. All private methods and member variables won't be accessible.