1

In my application im having a table widget , by using stylesheet i tried to change header border and cells background colors.refer my code below,

//to set cell background color as white
tableWidget->setStyleSheet(" QTableWidget::item { border: 1px solid white; }" );
//to set header background as white
tableWidget->setStyleSheet("QHeaderView::section{background-color: black;color:white;border: 1px solid white;}");

now i want to combine both in style sheet. Guide me how to combine above two stylesheets into 1 stylesheet.

SingerOfTheFall
  • 29,228
  • 8
  • 68
  • 105
shivcena
  • 2,023
  • 8
  • 24
  • 50

1 Answers1

1
//to set cell background color as white
QString styleSheet = " QTableWidget::item { border: 1px solid white; }";
//to set header background as white
styleSheet += "QHeaderView::section{background-color: black;color:white;border: 1px solid white;}";
tableWidget->setStyleSheet(stylesheet);

However, you can just put everything in a single line, there is no need to split your stylesheet into two parts like this.

SingerOfTheFall
  • 29,228
  • 8
  • 68
  • 105