set background color in a table.cellWidgetRC, type ComboBox

Find and share HowTos to various installations / configurations!
3 posts • Page 1 of 1
weirdal
Posts:34
Joined: Thu Mar 12, 2015 11:37 am

set background color in a table.cellWidgetRC, type ComboBox

Post by weirdal »

Hi

I have a table with a combobox widget in certain cells. If the selected entry of the embedded combobox matches a certain value, I want to set the cell's background color. How can I achieve this?

Obviously, it does not work with table.cellBackColRC(), probably because the widget is displayed on top.


Thank you in advance

Tobias

weirdal
Posts:34
Joined: Thu Mar 12, 2015 11:37 am

Re: set background color in a table.cellWidgetRC, type ComboBox

Post by weirdal »

Code: Select all

if (g_dsSelectedTypes.at(i).isEmpty())
{
  tabDpSelection.styleSheet(getStylesheet());
}

[...]

private string getStylesheet()
{
  return "QTableView QComboBox\n" + 
         "{\n" +
         "  background-color: red;\n" +
         "}";
}
This way the background color is changed for all comboboxes in the table, not just the particular one that I would like to highlight.

leoknipp
Posts:2928
Joined: Tue Aug 24, 2010 7:28 pm

Re: set background color in a table.cellWidgetRC, type ComboBox

Post by leoknipp »

It looks like you can either use a widget in a table cell or do a coloring.
Combining both options is not possible.

Best Regards
Leopold Knipp
Senior Support Specialist

3 posts • Page 1 of 1