jpujolf
31st March 2011, 07:55
Hi all,
I'm stuck in a bizarre error. I cannot return nothing but simple colors as BackgroundColorRole in my QAbstractItemModel's derived class
If I put some code like this in headerData method :
case Qt::BackgroundColorRole :
{
QLinearGradient gradient ( 0, 0, 1, 1);
gradient.setColorAt ( 0,QColor::fromRgb (10*section,20*section,100+10*section ));
gradient.setColorAt ( 1, QColor::fromRgb ( 255,255,255 ) );
return QBrush ( gradient );
}
my grid shows it's header(s) absolutely black.
I've tested the same code in a much simpler model I've created some time ago to test my grid and model and shows the expected result :
6173
but when I've translated those 4 lines of code into my very-much-complex application doesn't crash, but shows a "nice" black header ( and if I put this code inside data () method, shows a white background, not the black one )
Any clues ? Where can I search ? I've been debugging and my model returns in both cases the same QBrush. And when I return a QColor, it works OK...
case Qt::BackgroundColorRole :
return QColor::fromRgb (10*section,20*section,100+10*section ));
This is a capture of my grid, returning a Qbrush for headers & a QColor for Band header :
6174
I'll pay some virtual beers to the one that can point me to a valid clue !! :p
I'm stuck in a bizarre error. I cannot return nothing but simple colors as BackgroundColorRole in my QAbstractItemModel's derived class
If I put some code like this in headerData method :
case Qt::BackgroundColorRole :
{
QLinearGradient gradient ( 0, 0, 1, 1);
gradient.setColorAt ( 0,QColor::fromRgb (10*section,20*section,100+10*section ));
gradient.setColorAt ( 1, QColor::fromRgb ( 255,255,255 ) );
return QBrush ( gradient );
}
my grid shows it's header(s) absolutely black.
I've tested the same code in a much simpler model I've created some time ago to test my grid and model and shows the expected result :
6173
but when I've translated those 4 lines of code into my very-much-complex application doesn't crash, but shows a "nice" black header ( and if I put this code inside data () method, shows a white background, not the black one )
Any clues ? Where can I search ? I've been debugging and my model returns in both cases the same QBrush. And when I return a QColor, it works OK...
case Qt::BackgroundColorRole :
return QColor::fromRgb (10*section,20*section,100+10*section ));
This is a capture of my grid, returning a Qbrush for headers & a QColor for Band header :
6174
I'll pay some virtual beers to the one that can point me to a valid clue !! :p