linux - How do I inherit from and extend QCalendarWidget using C++ -
Currently QCalendarWidget supports SingleSelection or NoSelection I write a widget inherited from QCalendarWidget in Qt 4.6.2 Would like to be able and add the ability of the user to choose any day in the week and that custom week is selected.
For example, click on Thursday 5 August 2010 and meet all day from Saturday to 31 July to Friday August 6.
My experience with QT is limited and it has been a while since I have done some C ++ so I need to worry about implementing a Qt constructor or virtual destructors when Is inherited in QT, or is there any other harm? How do the headers and CPP files look like for this custom widget, and where is the best place to add my custom color logic and selection modes?
I used GCC version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) and QT 4.6.2
After reading QCalendarWidget, I think
First of all, the widgets included in the classes received from QObject should not be copy constructor. The explanation for this is that the QObject division is virtual, so no matter how you declare yourself.
When a class changes its behavior, find the virtual function. If there is no one, then it is a good sign that inheritance can not be the best way. In this situation, we have three virtual methods:
virtual QSize sizeHint () const; Virtual QSize minimumSizeHint (); CONST; Virtual Wide Paint Cell (Couponer * Painter, Constant QRect and Rectangle, Constt Quite Date and Date) Construction;
The first two are virtual from QWidget and work with shaping widgets. They are probably not important for the last time you want to be part of it: The whole week is chosen, when one day of that week is chosen by the user.
Now, for possible issues:
Selection mode property is non-virtual and, besides, enum-valuable. Enumerated types can not be expanded to include a new proposed week's selection price. If you do not have to change the selection mode on the runtime, you can safely ignore this property and only work with week selection (ignoring a property is a good sign that your widget might be in the < Q> QCalendarView should be not QCalendarView.)
QCalendarView is also a composite widget (unlike a label or push button). Internally, it is composed of a QTableView, several QToolButtons, a QSpinBox and so on. This type of widget is difficult to extend from heritage, because you do not have access to its internal and most behaviors (such as handling painting and input events) are done by internal widgets, not by QCalendarView. >
In some cases, you can hunt children's widget using findChildren ()
and modify their behavior by changing properties. It is likely to break, however, because Nokia Internal can vary from 4.6.2 to 4.6.3, as long as the public binary interface of the class is preserved.
Ask yourself if the new widget should be . If not and inherising you are taken to a dead end, consider copying QCalendarWidget's source code and making it friendly to your needs. You can go ahead and change the original widget to include your behavior and send back a merge request back to Nokia.
Comments
Post a Comment