[Qt-interest] Fwd: setData function to change color

Nikos Geronitidis geronik444 at gmail.com
Thu Oct 15 13:37:28 CEST 2009


the problem solved when reimplemented the *data* function and
returning the desired *QVariant* value..

*QVariant *CustomSqlQueryModel::*data(const QModelIndex &index, int role)
const
{
if (role == Qt::TextColorRole)
return QColor(Qt::red);
return QSqlQueryModel::data(index,role);
}*

---------- Forwarded message ----------
From: Nikos Geronitidis <geronik444 at gmail.com>
Date: Thu, Oct 15, 2009 at 1:13 PM
Subject: setData function to change color
To: qt-interest at trolltech.com


Hello list

I am trying to change the color of specific fields in a *QTableView*, with
the *setData* function.

I have made a subclass of QSqlQueryModel named CustomSqlQueryModel
and inside the constructor I use the following loop in order to change the
color:

*for (int i = 0; i < rowCount(); i++)
setData(index(i,1),QColor(Qt::red),Qt::TextColorRole));*

but this is not working, am I missing something?
thanks in advance.


-- 
Best Regards
Nikos Gerontidis



-- 
Best Regards
Nikos Gerontidis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091015/1df547d5/attachment.html 


More information about the Qt-interest-old mailing list