QTreeWidgetItems and gradients, is it possible?

  • Hi there,

    I have a QTreeWidget where I need the text of the different items to be of different colors. QTreeWidgetItem::setForeground works great as long as you use a brush that's a single color, but I thought it'd be nice to use linear gradients instead. However nothing I do seems to work. For example:

    QLinearGradient l_gradient(0,0,100,100);
    l_gradient.setColorAt(0, Qt::blue);
    l_gradient.setColorAt(1, Qt::white);

    QBrush l_brush (l_gradient);
    lp_item->setForeground(0, l_brush);

    appears to do nothing. Am I doing it wrong, or are gradients for tree widget items just not supported at this point?

    Thanks, Nir

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.