1

I have a grid that's display using a control that inherits from QTableView. Right now the grid is displayed left-to-right and then as things overflow, it goes to the next row like this

 -----------
| 1 | 2 | 3 |
|------------
| 4 |   |   |
|------------
|   |   |   |
 -----------

but I want it to go top-to-bottom first and then as things overflow, it should go to next column like this

 -----------
| 1 | 4 |   |
|------------
| 2 |   |   |
|------------
| 3 |   |   |
 -----------

I'm mostly a .Net developer and it's pretty trivial with .net winforms controls, but how do I get QTableView to do this?

Thanks

Professor Chaos
  • 8,850
  • 8
  • 38
  • 54

1 Answers1

3

The data displayed is a function of your model. The best way to change the behavior is to create a proxy QAbstractTableModel that swaps the rows and the columns. How complicated this will be will be dependent on your current model. It almost sounds like you have a linear model and that the view just presents it in a table-like fashion in which case you're probably using the wrong model.

If you really do have a linear model, consider using QAbstractListModel and QListView. The QListView then has a flow property that will allow you to choose between left-to-right and top-to-bottom.

Kaleb Pederson
  • 45,767
  • 19
  • 102
  • 147