zwngcn
27th November 2006, 07:15
Hi all,
In almost all the concrete widgets such as QLabel and QPushButton, the function of paintevent uses a private member QXXXXPrivate, so is it possible to subclass widget and reimplement paintevent by not using the father class's paintevent?
For example, a subclass MyLabel inherited from QLable, I want to the MyLabel be like this: every character of the label text is shown in differnt color. In this case, the QLabel's paintevent is not useful. You have to use the information of QLabelPrivate and reimplement the paintevent completely, so it is hard to reimplement paintevent.
Maybe I am wrong. But if it is hard to reimplement paintevent, why Qt is designed like that? Although subclassing from QWdiget is simple, someone want to subclass from concrete widget and draw the widget unlike to its father widget.
Thanks for your help.
In almost all the concrete widgets such as QLabel and QPushButton, the function of paintevent uses a private member QXXXXPrivate, so is it possible to subclass widget and reimplement paintevent by not using the father class's paintevent?
For example, a subclass MyLabel inherited from QLable, I want to the MyLabel be like this: every character of the label text is shown in differnt color. In this case, the QLabel's paintevent is not useful. You have to use the information of QLabelPrivate and reimplement the paintevent completely, so it is hard to reimplement paintevent.
Maybe I am wrong. But if it is hard to reimplement paintevent, why Qt is designed like that? Although subclassing from QWdiget is simple, someone want to subclass from concrete widget and draw the widget unlike to its father widget.
Thanks for your help.