QTableView - Selection background color
I am using the following code for set the style for the table in simulator(S6开发者_JAVA技巧0)(Nokia Qt SDK).
searchTable->setStyleSheet("background: rgb(255,255,255);color:rgb(0,0,0); font-family:Arial Narrow;font-size:20px; border: 4px outset rgb(255,255,255);gridline-color: #669933;"
"selection-background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #486909, stop: 1 white);"
);
But When I am selecting the element in the data I got the following output. Please find the attachment.
Please help me.... What I did wrong .. Thanks in advance.
I guess your mistake is that you set up the stylesheet only for QTableView and not for all it's child widgets: cells. You could try to write your style code into a ".qss" file, add it to your app's resource file and then load it into your main.cpp with this code:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
QFile file(":/qss/stylesheet.qss");
file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll());
file.close();
qApp->setStyleSheet(styleSheet);
w.show();
}
In your style file you have to write something like this:
QLineEdit{
border: 2px solid grey;
border-radius: 10px;
padding: 0 8px;
background: white;
selection-background-color:darkgrey;
}
In this way all QLineEdit widgets will be shown with your style rules.
精彩评论