Results 1 to 1 of 1

Thread: QtSqlRelationalTableModel question

  1. #1
    Join Date
    Jan 2011
    Location
    Richmond, VA
    Posts
    94
    Thanks
    14
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QtSqlRelationalTableModel question

    Yet another design question - moving on from my earlier one (still in design phase).

    I have unique data in one DB table. It is linked via a foreign key reference to a child table. Ideally I'd like to create a combobox which is populated by the values in my parent table. Upon selection (or creation of a new parent item), another combo box would be populated with the unique names of the children. Upon selection of a child, a QTableView would then be populated with the attributes of that particular child.

    For example:

    {Musician} -> This is the unique parent

    {Album} -> linked to the parent via foreign key; may not be unique based on current DB design

    By SELECTing an album, the QTableView would be populated with the album tracks.

    So my question is: I'd like to use q QSqlRelationalTableModel to handle editing of this data via widget mapping, but I'm wondering if that is a viable approach. My initial thoughts were that I'd have to manage this with 2 different models and keep it all in sync behind the scenes, especially when editing but obviously I don't know which in the end would be the easiest -- and cleanest -- approach (which I'm thinking about limiting to adding or copying due to other down-the-road issues).

    I should experiment with both to see but my time is very limited and I'm trying to avoid my father-in-law's theory of "code twice, throw away once" and nail down a solid design before I actually start coding...


    Added after 59 minutes:


    Actually, I think I just answered my own question as I found a very, very similar example in the C++ GUI Programming with Qt4, Second Edition book...
    Last edited by scott_hollen; 25th February 2011 at 17:04.

Similar Threads

  1. A question
    By Dante in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 12th March 2009, 20:11
  2. Question
    By Dumbledore in forum Qt Programming
    Replies: 1
    Last Post: 20th October 2007, 23:12
  3. .Net & C# question
    By mickey in forum General Programming
    Replies: 1
    Last Post: 20th November 2006, 14:25
  4. map question
    By mickey in forum General Programming
    Replies: 12
    Last Post: 10th June 2006, 18:40
  5. Question
    By KyrinComa in forum General Discussion
    Replies: 5
    Last Post: 19th May 2006, 01:36

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.