Results 1 to 3 of 3

Thread: Multiple open databases and MVC

  1. #1
    Join Date
    Jan 2012
    Posts
    46
    Thanks
    11
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Multiple open databases and MVC

    All --

    My application heavily relies on a model/view, connecting to a sqlite database, but now I'd like to off my user a chance to import another sqlite database, and I have no trouble getting both of them open, but is there a way to direct my models to know which database to get data from? Is there some way of directing the model->setTable("tablename") command to specify the database connection? I can perform the import via SQL but I'd prefer to set models on the database to import...

    thanks!


    Kodi

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Multiple open databases and MVC

    When you construct your QSqlTableModel model you specify which database connection to use rather than the default option of it using the default connection.

  3. The following user says thank you to ChrisW67 for this useful post:

    mtnbiker66 (25th March 2012)

  4. #3
    Join Date
    Jan 2012
    Posts
    46
    Thanks
    11
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Multiple open databases and MVC

    Ah, jeez, that's embarrassing...I completely missed that in the documentation...It's amazing how something sticks out so glaringly when it's pointed out...I'll wipe the egg off my face and go open a new beer


    Kodi

Similar Threads

  1. Replies: 1
    Last Post: 3rd January 2012, 11:25
  2. Switching between two databases
    By codeman in forum Qt Programming
    Replies: 20
    Last Post: 13th May 2009, 15:33
  3. Open multiple files with one program instance
    By Ginsengelf in forum Qt Programming
    Replies: 6
    Last Post: 16th March 2009, 15:08
  4. Qt and databases
    By gt.beta2 in forum Newbie
    Replies: 6
    Last Post: 18th February 2009, 09:39

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.