Results 1 to 6 of 6

Thread: tableview model view problem

  1. #1
    Join Date
    Oct 2007
    Posts
    65
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question tableview model view problem

    Hello, i am using two tableviews with qsqlquerymodel, in the first table i show the invoice headers and in the second the lines of every invoice (when i select the invoice in the first table with the mouse), i have any comboboxes and lineedit to filters the invoice headers, the problem i have is that when i use any of the invoice header filter i would like that the invoice lines table was cleared but if i use the .clear() method in the model i lose the header names setted with .setHeaderData, i have tried too setting and invalid qsqlquery with .setquery() but when i reload any invoice lines the columns lost his size, altough i am using tableview.resizeColumnsToContents() after every setquery in this table, i have tried too reset the tableview and headers but this doesnt works either so the only solution that i think i could use subclass qsqlquerymodel and reimplement headerdata function but i would like to avoid subclass qsqlquerymodel if possible, anyone has a better solution? Thanks.

  2. #2
    Join Date
    Oct 2007
    Posts
    65
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: tableview model view problem

    any good idea on this?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: tableview model view problem

    Why do you want to clear the model? I can't follow your concept... are you deleting something? Could you show a mockup image of what you do?

  4. #4
    Join Date
    Oct 2007
    Posts
    65
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: tableview model view problem

    here you can view a photo of the dialog, the table below is the lines of the document selected in the table above (headers and lines of tickets or invoices), the comboboxes and lineedit right to table are the filters of the above table when i apply a filter i would like to clean the table below (because the selected document it is loss) but i cant find any good way to do it, like i explain in first post.
    Attached Images Attached Images

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: tableview model view problem

    So you could say that the bottom table show "children" of the item selected in the upper table?

    If so, then why not make a proper hierarchical model with parents and children. Then populating the bottom table would be as simple as setting the root index to the index of the item selected in the upper table.

    Regardless of your decision, the headers could be changed by using a proxy model over the sqlquery (or your custom) model. You could also subclass QSqlQueryModel and return proper column names regardless of whether the resulting set contains any rows or not. Then clear() wouldn't remove your headers.

  6. The following user says thank you to wysota for this useful post:

    skuda (3rd December 2007)

  7. #6
    Join Date
    Oct 2007
    Posts
    65
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: tableview model view problem

    i think i will subclass qsqlquerymodel and reimplement headerdata, because it is much less work than do a proper sql model with parent and children

Similar Threads

  1. hierarchical model in a flat view
    By gniking in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 20:17
  2. Help with Model View
    By weepdoo in forum Qt Programming
    Replies: 13
    Last Post: 12th October 2007, 10:32
  3. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  4. Table Model / View Problem -- Data Not Displaying
    By jhendersen in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2007, 06:45
  5. Replies: 6
    Last Post: 20th April 2006, 10:23

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.