PDA

View Full Version : Span depending on data



Gbx
24th February 2017, 07:16
It is necessary to span the cell depending on the data, do it without any problems, but the problems are when used sort column - span is on the same place. I use the following code

connect(tableView->horizontalHeader(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(slotSetSpan()));

void tabData::slotSetSpan()
{
tableView->clearSpans();
for (int i = 0; i < tableView->model()->rowCount(); i++){
int code = tableView->model()->data((tableView->model()->index(i, 2))).toInt();
if(code == 125) tableView->setSpan(i, 3, 1, tableView->model()->columnCount() - 3);
}
}

Santosh Reddy
24th February 2017, 08:17
So what is the issue ? Is the code not working ?

Gbx
25th February 2017, 15:49
Thank you very much! You said that it must work and I found the mistake. It was that in used frozen table (like in Qt examples) the signal disappeared.