Nominate our 2022 Qt Champions!

Borders color in QTableWidget

  • Hi everyone here

    I wanted to modify a style of my QTableWidget, I added this line to do this :

    tableWidget->setStyleSheet(QLatin1String("QTableWidget#tableWidget{ background-color: rgba(255, 255, 255, 150);}"));

    but that removes the default style sheet, and the "borders" between lines become black.

    You can see the wrong borders there

    Is there any way to change this color, or to modify a single style of my widget ? And why the default stylesheet has been totally removed, and not just overridden ?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    When using stylesheets a special QStyle is used to render your styled widget. Since you are only modifying the background, changing the QPalette of your QTableWidget might be enough.

    Hope it helps