How to make table headers with custom background?
As in the thread title. I'm using QTableWidget Class to represent data in table.
I would like these headers:
http://img251.imageshack.us/img251/4...ytywaniebk.jpg
To look (for example) like this:
http://img688.imageshack.us/img688/2...wytywanieb.jpg
Is that possible? How to do it?
Re: How to make table headers with custom background?
You can achieve it by using style sheet file.
Create a file and name it mystyle.qss
To get custom header :
Code:
border: 0.5px solid #C2C7CB;
padding-left: 4px;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #59AAFC,
stop: 0.2 #C2C7CB,
stop: 0.5 #DFDFDF,
stop: 0.7 #C2C7CB,
stop: 1.0 #287ACC );
}
Set up the style for your app in the main function:
Code:
int main ( int argc, char* argv[])
{
QFile file(":/mystyle.qss");
if (file.
open(QFile::ReadOnly));
qApp->setStyleSheet(styleSheet);
// other code
return app.exec();
}
Create a resource file (myresource.qrc) and include your style file:
Code:
<RCC>
<qresource >
<file>mystyle.qss</file>
</qresource>
</RCC>
And finally add myresource.qrc in the application *.pro file:
Code:
RESOURCES = myresource.qrc
(In this example, the files created are relative to your app directory).
If you need to customize other widgets just add them to your qss file.
I encourage you to read about Qt resource and style sheet concepts.
Have a look at http://doc.trolltech.com/4.6/stylesh...stomizing.html to get more information.