Results 1 to 3 of 3

Thread: How to update QTableView from SQL database after adding data to database?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2014
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default How to update QTableView from SQL database after adding data to database?

    I have 2 classes, one is a mainwindow (iherits from QMainWindow), and second is addwindow (iherits from QDialog). In mainwindow I have QTableView connected with database, and buttons like "add data", "remove data". In addwindow I put data and click "ok" button to add data to database. Now, how could I call "tablica->select()" to update QTableView after clicked "ok" button in addwindow?

    Problem is that QSqlRelationalTableModel associated with QTableView is included in mainwindow constructor, and method adddata is included in addwindow class.

    There are my header and c++ files.

    mainwindowh.pngmaincpp.jpgmaincpp2.pngaddwindowh.pngaddwindowcpp.jpg

    EDIT: I just found after hours, that thing I supposed to do was add connection in clicking "add data" slot in mainwindow class.
    Last edited by Voonter; 5th April 2014 at 21:48.

Similar Threads

  1. Adding new record to database from QDataWidgetMapper
    By naptizaN in forum Qt Programming
    Replies: 4
    Last Post: 15th July 2012, 13:19
  2. How to update BLOB field in a SQLite database ?
    By aircraftstories in forum Qt Programming
    Replies: 6
    Last Post: 8th April 2011, 20:45
  3. QSqlTableModel the database does not update
    By Zander87 in forum Qt Programming
    Replies: 4
    Last Post: 27th February 2011, 22:34
  4. i can't update database,
    By xiongxiongchuan in forum Qt Programming
    Replies: 7
    Last Post: 29th June 2010, 14:44
  5. Replies: 1
    Last Post: 7th June 2008, 18:29

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.