PDA

View Full Version : Problem with reloading QHeaderView::paintsection() function.



rokky05
9th April 2009, 12:09
HI, I have next problem:

I need redraw headers column in Table, so I inherit from class QheaderView and reload function paintsection(). Then I just copy sources code from function QheaderView::paintsection() in my reloaded function CustomHeaderView::paintsection() and when I compile this, g++ gives next error in this line of code: Q_D(const QHeaderView);

"error: 'const QHeaderView::d_func() const' is private within this context "



Can someone tell me why?

spirit
9th April 2009, 12:26
trolls use Pimpl approach. so, you should look at QHeaderViewPrivate class, find and copy all varianble which are used in QHeaderView and then all should work.
note: if you saw code like this d-> that means that variable is located in QHeaderViewPrivate class.
you can also include #include "qheaderview_p.h", but this is bad idea.

rokky05
9th April 2009, 13:11
I think it is bad idea "find and copy all varianble which are used in QHeaderView" because then that function will worck not correctly.

spirit
9th April 2009, 15:09
this is not bad idea. bad idea it's using of private Qt's files.
but if you find all vars and add to your class then your class will work fine if you move to next version of Qt, but if you still want to use private Qt's file then ther is no guaranty that you code will work on next version of Qt. I had such situation.
btw, this is from one of Qt's private headers.


//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

wysota
9th April 2009, 22:49
How about simply calling the base class implementation where you need it?