Replacing icons of tabs QTabWidget with labels on customwidget
Hi,
I was looking for a way to replace the icon on the tab of a tabbed widget with a Qlabel so I can play a movie on it. I tried using settabbutton with a qlabel but it just resizes the label and puts it on the side of the icon. I would like to totally replace the icon with the label if possible and set the same size as the icon for the label. This is a standalone widget.
Re: Replacing icons of tabs QTabWidget with labels on customwidget
By default QTabWidget tab's don't have icons, you might have added it, just avoid adding it.
You can sub-class QTabWidget and implement the below virtual method, it will set the QLabel on to the tab of the newly added tab page(widget)
Code:
void myTabWidget::tabInserted(int index)
{
setTabText
(index,
QString());
//clear the title in the tab, if you want
label
->setFont
(QFont("Arial",
48,
100,
true));
tabBar
()->setTabButton
(index,
QTabBar::LeftSide, label
);
}