You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, September 29th 2011, 2:15pm

To Add Arrow Image on table header

Hi,

Could you please explain in steps how to proceed in adding a image to the table header columns.

I have a table with 2 header columns (Name, Address). when user sorts data in ascending order on Name column i need to add customized image( customized Up arrow image) next to Name header column.

Thanks.

2

Sunday, October 2nd 2011, 11:02pm

This can do the job:

QTableWidgetItem* item = new QTableWidgetItem("Column Header Text");
item->setIcon(*(new QIcon("uparrow.png")));
table->setHorizontalHeaderItem(2,item);
techn_mike has attached the following file:
  • headerIcon.png (5.3 kB - 5 times downloaded - latest: Mar 21st 2013, 3:23pm)

3

Monday, October 3rd 2011, 5:39am

Thanks,
But actually i am using QTableView not QTableWidget;

Any other hits

Thanks

Junior

Professional

  • "Junior" is male

Posts: 1,613

Location: San Antonio, TX USA

Occupation: Senior Secure Systems Engineer

  • Send private message

4

Monday, October 3rd 2011, 6:16pm

You could try using a style sheet setting:

Source code

1
2
3
4
5
6
7
8
/* style the sort indicator */
 QHeaderView::down-arrow {
     image: url(down_arrow.png);
 }

 QHeaderView::up-arrow {
     image: url(up_arrow.png);
 }

5

Tuesday, October 4th 2011, 6:32am

Thanks,
It is working(But Partially)
it means when i am writing code like..

QHeaderView::section {

background-color: lightblue;

color: black;
}

I shows the changes.

But when i am doing like as...

/* style the sort indicator */
QHeaderView::down-arrow {
image: url(123.png); //123.png is local file
}

nothing is reflected on header.

Am i missing something???

Thanks.

This post has been edited 3 times, last edit by "Sanjay123" (Oct 4th 2011, 8:01am)


Similar threads

Used tags

placement1