PDA

View Full Version : changing color of QTable



aj2903
30th October 2009, 08:29
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?

zgulser
30th October 2009, 09:30
if itemClicked
set all items color to default
set the clicked item's color to xyz

aj2903
30th October 2009, 10:04
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.

zgulser
30th October 2009, 10:14
Ok, then set the table to accept multi selection additionaly. Is that what you want?

aj2903
30th October 2009, 10:22
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 ?

zgulser
30th October 2009, 10:24
Sure, you can set the property from the designer.

aj2903
30th October 2009, 10:30
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?

zgulser
30th October 2009, 12:52
well it should be something like;




connect( yourTableWidget,
SIGNAL(itemClicked(Item*)),
this,
SLOT(itemClickedSlot(Item*)));

...


void itemClickedSlot(Item* myItem)
{
for each item in the table widget item
item->setStyleSheet("background-color:rgb(white/default color)");

myItem->setStyleSheet("background-color:rgb(clickedcolor)");
}