| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 1 | |
Hi I'm trying to adjust the positions of columns in a table view linked to a SqlRelationalTableModel. I want to be able to add an additional column containing static data and also reorder the columns in the view differently to the sequence the fields that are returned from the select query. I can successfully remove the primary key field using removeColumn(0), but when I try and insert a column using insetColumn(2), whilst I correctly get an extra column in the table view all the data after the insert is shifted 2 columns to the right (and I therefore also lose the data from the final field). i.e. originally: col1 col2 col3 col4 data1 data2 data3 data4 after insertColumn(2): col1 col2 newcol col3 col4 data1 data2 data3 So my 2 questions are: 1. Am I able to reorder the columns to appear in a different sequence to that which is returned in the result set for the select query? (I've looked at altering the select query but can't see a call on the api to do this) 2. Why when I insert a column does the data shift 2 columns right rather than 1? Andy -- [ signature omitted ]
Hi Have you noticed QHeaderView::moveSection()? The horizontal header view is accessible via QTableView::horizontalHeader(). -- [ signature omitted ]