qtbackgroundtransparencyqtablewidget

How to set QTableWidget background transparent in Qt?


I am developing an app in which I am using QTableWidgets, and I need to set their background transparent, I have tried to setStyleSheet "background:transparent;", but nothing happened.

Is there any other way to do it?

enter image description here


Solution

  • 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.