Results 1 to 8 of 8

Thread: changing color of QTable

  1. #1
    Join Date
    Sep 2008
    Posts
    84
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default changing color of QTable

    i'm having n number of rows in table.

    My problem is :

    1.When the user selects one row from table, the row color should be changed to xyz color.
    How can this be done?

  2. #2
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: changing color of QTable

    if itemClicked
    set all items color to default
    set the clicked item's color to xyz

  3. #3
    Join Date
    Sep 2008
    Posts
    84
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: changing color of QTable

    thanks for replying.

    my problem is , first user selects 2row then its' color should be changed.
    After selecting 2nd row, user can select 10 row, so 2nd & 10th row will have same color.

  4. #4
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: changing color of QTable

    Ok, then set the table to accept multi selection additionaly. Is that what you want?

  5. #5
    Join Date
    Sep 2008
    Posts
    84
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: changing color of QTable

    another problem is when the item is clicked,there is confirm button.
    on clicking confirm we have to change it's color.

    Also is there any property of mutli-selection in table widget ?

  6. #6
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: changing color of QTable

    Sure, you can set the property from the designer.

  7. #7
    Join Date
    Sep 2008
    Posts
    84
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: changing color of QTable

    i have set the mutli-selection property from Designer.

    But i'm not able to change the color of the selected row.
    can u just give snippets of code or any link where such problem has been solved?

  8. #8
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: changing color of QTable

    well it should be something like;

    Qt Code:
    1. connect( yourTableWidget,
    2. SIGNAL(itemClicked(Item*)),
    3. this,
    4. SLOT(itemClickedSlot(Item*)));
    5.  
    6. ...
    7.  
    8.  
    9. void itemClickedSlot(Item* myItem)
    10. {
    11. for each item in the table widget item
    12. item->setStyleSheet("background-color:rgb(white/default color)");
    13.  
    14. myItem->setStyleSheet("background-color:rgb(clickedcolor)");
    15. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QTable - paintCell() - how to do with it?
    By mp33919 in forum Qt Programming
    Replies: 8
    Last Post: 23rd April 2009, 20:55
  2. QTable Sorting
    By mromey in forum Qt Programming
    Replies: 1
    Last Post: 23rd April 2009, 08:28
  3. Replies: 0
    Last Post: 7th April 2008, 15:27
  4. Problem with QTable
    By zlatko in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2006, 11:00
  5. QTable..Vs.. QListView
    By :db:sStrong in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2006, 22:03

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.