PDA

View Full Version : How to use setSpan in QTableView



3str
3rd August 2011, 04:46
Hi,

I'm using a QTableView with a QAbastractTableModel. In some rows in the table, all columns should be merged into one cell, according to the model data. I'm confused that setSpan is a function of the viewer class, not the model class. Then how should I use setSpan to achieve my goal?

I tried to subclass QTableView and modify setModel function. Call setSpan inside setModel, didn't work....

Thanks!

Santosh Reddy
3rd August 2011, 08:14
It should be simple, you could do this with out custom view, just set the cell span


QTableView view;
view.setModel(model);
view.setSpan(0, 0, 1, model->columnCount()); //sets the 1st row 1st column cell to span over all the columns
view.show();

3str
3rd August 2011, 14:01
Thanks. This is very straightforward. I was expecting some trick that the Model/View framework could handle this automatically.