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. SQL relational table update
Forum Update on Monday, May 27th 2025

SQL relational table update

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 421 Views
  • 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.
  • D Offline
    D Offline
    Dan3460
    wrote on 21 May 2016, 21:54 last edited by
    #1

    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
    0

    1/1

    21 May 2016, 21:54

    • Login

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