Results 1 to 6 of 6

Thread: QTableWidget selected row background

  1. #1
    Join Date
    Jul 2010
    Posts
    23
    Thanks
    5

    Default QTableWidget selected row background

    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!!

  2. #2
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableWidget selected row background

    See below link, if it can solve your problem.

    http://stackoverflow.com/questions/7...a-qtablewidget

  3. #3
    Join Date
    Jul 2010
    Posts
    23
    Thanks
    5

    Default Re: QTableWidget selected row background

    Quote Originally Posted by Rajesh.Rathod View Post
    See below link, if it can solve your problem.

    http://stackoverflow.com/questions/7...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:

    main.png

  4. #4
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableWidget selected row background

    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.

  5. #5
    Join Date
    Jul 2010
    Posts
    23
    Thanks
    5

    Default Re: QTableWidget selected row background

    Quote Originally Posted by Rajesh.Rathod View Post
    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!

  6. #6
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableWidget selected row background

    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.
    Last edited by Rajesh.Rathod; 6th May 2014 at 05:33.

Similar Threads

  1. QTableView--keep same background color when selected
    By davethomaspilot in forum Qt Programming
    Replies: 0
    Last Post: 11th February 2014, 17:38
  2. Replies: 2
    Last Post: 12th December 2012, 02:40
  3. background color of not selected tab
    By iridium in forum Qt Programming
    Replies: 0
    Last Post: 13th August 2009, 15:57
  4. QHeaderView: background of selected header item with CSS
    By antarctic in forum Qt Programming
    Replies: 5
    Last Post: 8th June 2009, 07:37
  5. Background of a selected QItemDelegate
    By schall_l in forum Qt Programming
    Replies: 4
    Last Post: 23rd May 2008, 07:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.