我正在开发一个使用 QTableWidgets 的应用程序,我需要将其背景设置为透明,我曾尝试setStyleSheet "background:transparent;"从表单中设置,但没有任何反应,还有其他方法吗?我发布截图

我正在开发一个使用 QTableWidgets 的应用程序,我需要将其背景设置为透明,我曾尝试setStyleSheet "background:transparent;"从表单中设置,但没有任何反应,还有其他方法吗?我发布截图

你在正确的轨道上。尝试:
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);
请注意,我在创建表格小部件之前设置样式表。我不知道为什么,但这似乎是必要的。