Set the QTabWidget background to be transparent by stylesheet but useless in VS2013

Viewed 378

I set a picture as background in the mainframe and add two widgets on it: a QTableWidget and a QTabWidget.

  1. I have set the background of tablewidget to be transparent by stylesheet in vs2013. The table's background shows the picture I set but the horizontalheader section is still white:

TaskInfWidget_->setStyleSheet("QTableWidget{background:transparent;}\
                           QTableWidget::item{border-top:1px solid grey;border-bottom:none;border-right:none;border-left:none;}\
                           QHeaderView::section{background:transparent;color:black; font-family:宋体;font-size:15px;font-weight:200;\
                                                    border:none;}");

  1. But when I add a tablewidget in a tabwidget and set the stylesheet of the tabwidget, it doesn't work:

QTabWidget *tab_widget=new QTabWidget;
QTableWidget *table = new QTableWidget(10, 1);
tab_widget->addtab(table,"hahaha");

tab_widget>setStyleSheet("QTabWidget::pane{background:transparent}\
            QTabBar::tab{background-color:transparent;height:30px;}\
            QTabBar::tab:selected{background-color:rgb(55,112,183)}\
            QTabBar::tab:hover{color:rgb(235,97,0);}");
table->setStyleSheet("QTableWidget{background:transparent;\
                         border:3px solid rgb(30,77,135);\
                         selection-background-color:rgb(30,77,135);}");

I have set QTabWidget::pane{background:transparent} and QTableWidget{background:transparent}, but the background of the tablewidget is still white, not the picture of the mainframe.

This is my first time to ask question here. This question has bothered me several days. Who can tell me the reason?

0 Answers
Related