[SOLVED]Blink text in table
-
wrote on 26 Oct 2011, 07:36 last edited by
I got at tableview with items from a model.
Some of the rows should "Blink"
Just like in html and the Blink tagI Use a QBrush (myBlink) to set the color of the text.
In a timerevent I simple change the Qbrush (myBlink) color but nothing happens.
I know that the timerevent runs.
I have tried to repaint the tabelview but nothing happens.
is it possible to do like this:
Maybe i should use the paintevent or something;
pls help -
wrote on 26 Oct 2011, 12:04 last edited by
if you have a custom model (so using the QTableView, not QTableModel), you could change the data in the model and send dataCHanged signal. If you use the widgets style (QTableWidget) you can change the background color for the item in the widget. it should update immediatly.
-
wrote on 26 Oct 2011, 12:53 last edited by
Thank you but i don't think that this is the solution.(Maybe!)
I suppose that I have to loop thru the whole model if I use your replay.
and set the datamodels data.That's a final solution that I hope to avoid
-
wrote on 26 Oct 2011, 13:22 last edited by
You can't avoid that solution. You MUST emit dataChanged with a proper range in order to make the view fetch the new values for the foreground text color (then provide the new color in data()).
-
wrote on 26 Oct 2011, 13:57 last edited by
Ok I try
Any cute loop to use
Maybe@foreach(datamodel.rowcount,datamodel.columnCount){}
@
or -
wrote on 27 Oct 2011, 08:54 last edited by
Do you have a standard model or a custom one?
If you have a custom model, it's fairly trivial. Yust store the data inside it and call
@
emit dataChanged(createIndex(firstRow, blinkColumn), createIndex(lastRow, blinkColumn));
@ -
wrote on 1 Nov 2011, 06:40 last edited by
I solved it in my own way.
@void Logs::BlinkTextRows(){
int row_count = model->rowCount(); int col_count = model->columnCount(); QModelIndex index; for( int i = 0; i < row_count; i++ ) { if (model->item(i,3)->data(Qt::DisplayRole).toString().compare("yes",Qt::CaseInsensitive) == 0) { if (model->item(i,4)->data(Qt::CheckStateRole) == Qt::Unchecked) { for (int j = 0;j < col_count;j++) { index = model->indexFromItem(model->item(i,j)); if (hidden) model->setData(index, myblink, Qt::ForegroundRole); else model->setData(index, myblink, Qt::ForegroundRole); }//for } //if model.. } //if compare }//For i if (hidden) hidden = false; else hidden = true;
}@
It wasn't so hard in the end
1/7