Results 1 to 5 of 5

Thread: Resetting Tableview...

  1. #1
    Join Date
    Jun 2006
    Posts
    64
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Resetting Tableview...

    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.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Resetting Tableview...

    Quote Originally Posted by b1 View Post
    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()?
    J-P Nurmi

  3. #3
    Join Date
    Jun 2006
    Posts
    64
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Resetting Tableview...

    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.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Resetting Tableview...

    How do you invoke it? Try running your program with gdb and checking the backtrace.
    J-P Nurmi

  5. #5
    Join Date
    Jun 2006
    Posts
    64
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Resetting Tableview...

    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.

Similar Threads

  1. TreeView, TableView
    By rbrand in forum Qt Programming
    Replies: 1
    Last Post: 4th July 2006, 08:54
  2. Modified tableview
    By dkite in forum Qt Programming
    Replies: 2
    Last Post: 14th March 2006, 01:58
  3. How to set the alignment in a TableView?
    By vratojr in forum Qt Programming
    Replies: 1
    Last Post: 9th March 2006, 13:21
  4. Widgets in TableView
    By boonie in forum Qt Programming
    Replies: 4
    Last Post: 21st February 2006, 19:55
  5. I can't assign TableView signals...
    By tomek in forum Newbie
    Replies: 5
    Last Post: 9th January 2006, 21:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.