Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Unsolved SQL relational table update

    General and Desktop
    1
    1
    357
    Loading More Posts
    • 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.
    • Dan3460
      Dan3460 last edited by

      I'm learning to use qt and sql. I tested a very similar program with QSqlTableModel and I can edit the data directly from the table view in the dialog. When I use QSqlRelationalTableView, which inherits QSqlTableModel the changes on the table are not transfer to the database. Is there a command to give to update the database?
      I'm just playing with this now but eventually I will be building an application where I can add and modify certain data from the application.

      Dialog::Dialog(QWidget *parent) :
      QDialog(parent),
      ui(new Ui::Dialog)
      {
      ui->setupUi(this);

      db = QSqlDatabase::addDatabase("QMYSQL");
      
      db.setHostName("192.168.1.14");
      db.setDatabaseName("Radio");
      db.setUserName("aaaaa");
      db.setPassword("bbbbb");
      
      if(db.open()==false)
      {
          QMessageBox::warning(this,"Error","Coudl not Open Database");
      }
      
      model = new QSqlRelationalTableModel(this);
      model->setTable("Brand");
      model->setRelation(7,QSqlRelation("Poster","idPoster","posterName"));
      model->select();
      ui->tableView->setModel(model);
      

      }

      1 Reply Last reply Reply Quote 0
      • First post
        Last post