In other way you have to redefine the tabSizeHint(), because you will not use it, but other objects will, so you have to tell them what the sizeHint is. And you can do it in tabSizeHint(). Something like this:
Let's say that ClassA uses ClassB and want to know what is the object of ClassB size just to know how to paint it. So the code can be:
class ClassB
{
public:
. . .
QSize sizeHint
() const { return QSize(100,
100);
} };
class ClassA
{
private:
ClassB classb;
public:
void paint() {
paintSomethingInRect(something, rect);
}
};
class ClassB
{
public:
. . .
QSize sizeHint() const { return QSize(100, 100); }
};
class ClassA
{
private:
ClassB classb;
public:
void paint() {
QRect rect(QPoint(0, 0), classb.sizeHint());
paintSomethingInRect(something, rect);
}
};
To copy to clipboard, switch view to plain text mode
In your situation ClassB = QTabBar and ClassA = QTabWidget; And as you see QTabWidget and some QTabBar methods want to know how big tabbar is so they ask it through tabSizeHint() method. That's why you have redefined the tabSizeHint().
P.S. By the way: these things, like "subclassing", "override" and so on are basics of C++ programming, so I think you should equipped yourself with some C++ books/tutorials/websites.
Bookmarks