2012-04-25 486 views
1

我正在开发一个应用程序,其中我使用QTableWidgets,并且我需要将其背景设置为透明,我尝试从表单中尝试setStyleSheet "background:transparent;",但没有任何事情发生,是否有任何其他方式可以执行此操作?我张贴的截图如何在Qt中设置QTableWidget背景透明?

enter image description here

回答

7

你在正确的轨道上。尝试:

setStyleSheet("QTableWidget {background-color: transparent;}" 
       "QHeaderView::section {background-color: transparent;}" 
       "QHeaderView {background-color: transparent;}" 
       "QTableCornerButton::section {background-color: transparent;}"); 
QTableWidget *table = new QTableWidget(latticeView); 
table->setRowCount(2); 
table->setColumnCount(2); 

请注意,我在创建表小部件之前设置样式表。我不知道为什么,但似乎是必要的。