Would you like the whole row to be filled with background color?
Would you like the whole row to be filled with background color?
J-P Nurmi
@aamer4yu: doesn't work
@jpn: yes. How can i do that?
Here's an idea:
- subclass QTreeWidget
- reimplement QTreeView::drawRow()
- fill the whole row with desired background color
- call the base class implementation to draw actual content
J-P Nurmi
I need help:
Qt Code:
void MyTree::drawRow( QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const { painter->save(); painter->fillRect( rect, brush ) // how can i get rect ( QRect ) ? painter->restore(); }To copy to clipboard, switch view to plain text mode
I got the rectangle from the option with option->rect but the items are still with the default background color...
I am trying to figure this one for the past couple of days... Swiety, if you have figured it out can you please share with me your way of solving it
I also tryed (sorry about the syntax error I translated this from Python to C++ since my code is in Python):
painter->fillRect(option->rect, QColor(233, 233, 233))
option->palette->setBrush(QPalette->Base, QColor(255, 0, 0))
This will give me the whole tree background to be grey (QColor(233,233,233) insted of being red... And I cannot find the connection between the painter and the palette...
Please help...
// how can i get rect ( QRect ) ?
do get rect pls use option.rect
The next line will do the trick:
for (int col = 0; col < treeWidget->columnCount(); col++) TreeWidgetItem->setBackgroundColor(col, QColor(255, 255, 0, 100));
Bookmarks