PDA

View Full Version : Resetting Tableview...



b1
26th September 2006, 06:00
G'Day,

I have a simple QTableView ( myTableView )that displays the results of an QSqlQueryModel. This works fine.
I have a QPushbutton that runs a simple function to clear the screen (lineEdits, radioButtons, etc). I would like this to clear the QTableView also but cannot get it to work.

I have tried "myTableView->reset();" which compiles without erros but doesn't clear the table.

Any thoughts, pointers, suggested reading would be greatly appreciated.

Thanks, B1.

jpn
26th September 2006, 06:16
I have tried "myTableView->reset();" which compiles without erros but doesn't clear the table.
This will just reset the internal state of the view (state, possibly hidden rows/cols, etc..). It will not empty the model. But how about QSqlQueryModel::clear()?

b1
26th September 2006, 07:04
Thanks for the prompt reply, jpn.

I just tried the QSqlQueryModel::clear() and although it compiles it seg faults at run time.

Thanks anyway, B1.

jpn
26th September 2006, 07:32
How do you invoke it? Try running your program with gdb and checking the backtrace.

b1
26th September 2006, 07:57
I fixed it!!!

Thanks for the push, jpn. You got me set of in the right direction.

My problem was I was creating the QSqlQueryModel in one function then clearing it another. I now create the model outside the first function and all is well, no seg fault.

I also had to add myTableView->reset() to the my clearing function.

Thanks for the help, jpn.

Cheers, B1.