Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt Sql Join question

Qt Sql Join question

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 618 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lukeQt
    wrote on last edited by
    #1

    Hi Everyone,

    Sorry if this question has been answered already. I believe there are more then one way to approach this problem. I have a database I have a table for cities and a table for country. This is a one to many relationship. I have country setup like this model->setRelation(3, QSqlRelation("country", "id", "name"));. That works wonderful. But I want to have another column in my model that is for city. I only want to return the cities that are in Germany and not all cites. Could I use a proxy model for this? Could I query the database and return all cities that are in Germany? Summerfield queries the database for this. Could you use a join? Could you overload the data and set data methods for QtSql.QSqlRelationalTableModel? I am looking for the least resistance method. I believe that there could be more then one way to solve this problem. I am unsure of the best way to approach this problem?

    Also what if there was a one to one relationship how would you do it in this case, because it doesn't make sense to have a combobox with only one value in it? Could you use set data method? How would that look?

    Thank you,
    Luke

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved