如何在Qt中为QTabWidget设置背景图像?
我已经尝试过以下代码,但它不起作用:
ui->tabWidget->setStyleSheet("background-image: url(:/images/img.jpg);");
我可以为QTabWIdget的特定选项卡设置背景图像吗?
答案 0 :(得分:3)
这是设置QTabWidget
Tab
样式并设置Image
的代码:
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);