Color of text in Qtableview

Asked

Viewed 60 times

1

Hello, I am trying to implement text color in certain column of my Qtableview, unsuccessfully

to paint the cell, just use the code below on my delegate that works:

painter->fillRect(option.rect, QColor(255, 40, 0));

To change the color of the text was trying:

painter->setPen(Qt::red);

but it didn’t work.

Could someone give me a hand?

thank you, Juliano.

  • Depending on what you want to do, it is much more practical to reimplement this here: http://doc.qt.io/qt-5/qabstractitemmodel.html#data - then you will simply return what you want, according to the role. If the role for text, you can return the value. If the role for front or background color, return the color/texture you want. If nothing custom returns, it uses the default.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.