Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set QTableWidget background transparent in Qt?

I am developing an app in which I am using QTableWidgets, and I need to set its background transparent, I have tried to setStyleSheet "background:transparent;" from form, but nothing happened, is there any other way to do it? I am posting a screenshot

enter image description here

like image 867
abhishek Avatar asked Dec 21 '22 22:12

abhishek


1 Answers

You're on the right track. Try:

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);

Note that I'm setting the style sheet before creating the table widget. I don't know why, but that seems to be necessary.

like image 141
Anthony Avatar answered Dec 28 '22 06:12

Anthony