user2444217
user2444217

Reputation: 591

Qt Setting A TabBar

I am making an application using the Qt Framework and I run into a problem: I define a TabWidget like this

QTabWidget *armaTab = new QTabWidget();
armaTab->setContentsMargins(0, 0, 0, 0);
armaTab->setTabPosition(QTabWidget::North);
armaTab->setObjectName(QString::fromUtf8("armaTab"));

then I try to add a QTabBar Like This:

QTabBar *tabBar = new QTabBar();
tabBar->setContentsMargins(0, 0, 0, 0);
tabBar->setFont(*font);
tabBar->setObjectName(QString::fromUtf8("armaTabBar"));
armaTab->setTabBar(tabBar);

And I get this error:

error: 'void QTabWidget::setTabBar(QTabBar*)' is protected
error: within this context

May someone please explain where my mistake lies?

Upvotes: 0

Views: 534

Answers (1)

CapelliC
CapelliC

Reputation: 60034

that simply means that you must follow some attention to access the component: from docs:

void QTabWidget::setTabBar ( QTabBar * tb ) [protected]

Replaces the dialog's QTabBar heading with the tab bar tb. Note that this must be called before any tabs have been added, or the behavior is undefined.

I think you can simply subclass QTabWidget to get access to protected member(s)...

Upvotes: 1

Related Questions