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. MySQL table views are not updating
Forum Updated to NodeBB v4.3 + New Features

MySQL table views are not updating

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 407 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
    dencla
    wrote on 7 Apr 2023, 02:56 last edited by
    #1

    I have an application that is displaying MySQL table information in QTableViews in the ui editor. When I update a value in the database table I do not see it update the views unless i shut down the program and restart it the value updates in the database. As a note I am looking at a dataview in the database that consists of content from several tables. I do not know if this is a issue.

    I wold like to know if there is a function that I can call that will redisplay the value from the database in the current views.

    I also have a QTableWidgetView that is doing the same thing. they are all looking at:

        QTextStream(&strSQL) << "SELECT * FROM Scheduleview WHERE Status = 'Ready' ;
    

    I am changing the Status from "Ready' then to 'Running" then 'Complete' and showing the Table in different views that I wish to update.

    ui->CompleteView->setStyleSheet("QTableView::item::alternate{ background-color:#bfffbf; } QTableView::item {background-color:#deffde; }");
    
    ui->CompleteView->setModel(rdb.queryComplete);
    
    ui->RunView->setStyleSheet("QTableView::item::alternate{ background-color:#bfffbf; } QTableView::item {background-color:#deffde; }");
    
    ui->RunView->setModel(rdb.queryRunning);
    

    I am looking for any ideas, I have searched the internet and the documentation and Don't see anything tat seems to work.

    C 1 Reply Last reply 7 Apr 2023, 05:32
    0
    • D dencla
      7 Apr 2023, 02:56

      I have an application that is displaying MySQL table information in QTableViews in the ui editor. When I update a value in the database table I do not see it update the views unless i shut down the program and restart it the value updates in the database. As a note I am looking at a dataview in the database that consists of content from several tables. I do not know if this is a issue.

      I wold like to know if there is a function that I can call that will redisplay the value from the database in the current views.

      I also have a QTableWidgetView that is doing the same thing. they are all looking at:

          QTextStream(&strSQL) << "SELECT * FROM Scheduleview WHERE Status = 'Ready' ;
      

      I am changing the Status from "Ready' then to 'Running" then 'Complete' and showing the Table in different views that I wish to update.

      ui->CompleteView->setStyleSheet("QTableView::item::alternate{ background-color:#bfffbf; } QTableView::item {background-color:#deffde; }");
      
      ui->CompleteView->setModel(rdb.queryComplete);
      
      ui->RunView->setStyleSheet("QTableView::item::alternate{ background-color:#bfffbf; } QTableView::item {background-color:#deffde; }");
      
      ui->RunView->setModel(rdb.queryRunning);
      

      I am looking for any ideas, I have searched the internet and the documentation and Don't see anything tat seems to work.

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 7 Apr 2023, 05:32 last edited by Christian Ehrlicher 4 Jul 2023, 05:33
      #2

      How do the values change? From your program or externally? MySQL has no notification support so when it is changed from an external source you have to re-execute the query every time you want to see the new value.
      If you change the database by yourself you can listen on the dataChanged() or similar functions and trigger the update on the other view accordingly.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • D dencla has marked this topic as solved on 13 Apr 2023, 02:03

      1/2

      7 Apr 2023, 02:56

      • Login

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