PDA

View Full Version : QTableWidget selected row background



jbarrena
29th April 2014, 08:41
Hi,

I am developing an application that should display some values in different tables. I am using QTableWidgets which are customized based on customer's requirements, and one of these requirements is to modify the background image of each selected row in the table. I tried QTableWidget::item:selected{ background-image: url(:/new/prefix1/selected);} but it changes each item (column) in the row, and I need to change the whole row.

Is it possible?? Some help will be really appreciated!!

Thanks!!

Rajesh.Rathod
30th April 2014, 11:21
See below link, if it can solve your problem.

http://stackoverflow.com/questions/7840325/change-the-selection-color-of-a-qtablewidget

jbarrena
30th April 2014, 13:49
See below link, if it can solve your problem.

http://stackoverflow.com/questions/7840325/change-the-selection-color-of-a-qtablewidget

Thank you for the response, but I have already tried it. The problem is that it changes each cell´s background image, instead of the whole row backgroung image.

Here you have an image for the problem:

10329

Rajesh.Rathod
2nd May 2014, 10:45
From your screenshot , it seems you should try following two points:
1. Read selection behavior in Qt documentation and try QAbstractItemView::SelectRows.
2. you should also change your selection image to rect instead of roundrect , if you want them intentionally then for first and last column you can provide roundrect images and for middle columns you should provide rect images.

jbarrena
5th May 2014, 15:36
From your screenshot , it seems you should try following two points:
1. Read selection behavior in Qt documentation and try QAbstractItemView::SelectRows.
2. you should also change your selection image to rect instead of roundrect , if you want them intentionally then for first and last column you can provide roundrect images and for middle columns you should provide rect images.

So it is not possible to assign a background image to a selected row, isnt´t it? The problem is that with the suggested solution the vertical lines for the columns will not disappear, they will remain in the table, so it will not act as a "whole row".

Even if it did not help us as much as we wanted, thanks fr four replays!

Rajesh.Rathod
6th May 2014, 05:28
You can also hide the grid lines for the QTableWidget , try void setShowGrid(bool show) function and in case if you want only horizontal grid lines you can draw it or you can select such a image with line at bottom/top.