Reputation: 20726
How can I set a background image for the QTabWidget in Qt?
I've already tried the following code, but it doesn't work:
ui->tabWidget->setStyleSheet("background-image: url(:/images/img.jpg);");
And can I set a background image for the specific tab of the QTabWIdget?
Upvotes: 1
Views: 2798
Reputation: 158
This is the code to set the style of QTabWidget
Tab
and set Image
on to it:
QString category = "QTabBar::tab:first { height: 30px; width: 100px;border-image: url(/home/vx/Downloads/Images/category.png); }";
QString counter= "QTabBar::tab:middle { height: 30px; width: 100px;border-image: url(/home/vx/Downloads/Images/counter.png); }";
QString user="QTabBar::tab:last { height: 30px; width: 100px;border-image: url(/home/vx/Downloads/Images/user.png); }";
ui->TB_main->tabBar()->setStyleSheet(category+counter+user);
Upvotes: 3