Results 1 to 3 of 3

Thread: QSqlRelation confusion, this should be simple.

  1. #1
    Join Date
    Jan 2009
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QSqlRelation confusion, this should be simple.

    I got two tables (actually, tons, but lets focus on these), this is their setup:
    Qt Code:
    1. CREATE TABLE Content (id INTEGER NOT NULL PRIMARY KEY, title TEXT NOT NULL, released DATE, rating INTEGER, tagline TEXT,plot TEXT, ended DATE,status TEXT);
    2. CREATE TABLE Url (id INTEGER NOT NULL PRIMARY KEY, contentId INTEGER NOT NULL REFERENCES Content (id), url TEXT NOT NULL, scraper TEXT);
    To copy to clipboard, switch view to plain text mode 

    Every content can have a list of url's connected to them. And I got an editwindow that shows all the data in content quite nicely, and then I wanted to add (using sql relations) url's to a view of it's own, that's where my problems come in.

    Every example I can find uses a foreign key in the main table to referance a remote table, however I dont have that, it's a foreign key in the remote table linking back.

    Is there any way to use sql relations to get a model of urls from the content model? Or will I have to setup a seperate url model?

  2. #2
    Join Date
    Jan 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSqlRelation confusion, this should be simple.

    You probably have to set up a separate model for the url.

    My experiences with the relational table models usually goes as follows:

    - Set up the models
    - Get the views to work properly
    - Struggle to get edits of the relational data to work
    - Rewrite the whole thing as a QAbstractItemModel (or equivalent)
    - Get edits working
    - ???
    - Profit

  3. #3
    Join Date
    Jan 2009
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSqlRelation confusion, this should be simple.

    hmpf :/, I was really hoping for some tools to work with a table model that simple. Oh well, I'll work around it, thanks for your help

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.