Results 1 to 2 of 2

Thread: Monitoring changing data of a database via QSqlRelationalmodel and QDatawidgetMapper

  1. #1
    Join Date
    Dec 2013
    Posts
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Monitoring changing data of a database via QSqlRelationalmodel and QDatawidgetMapper

    Hello,

    i try to display data of a database record which changes from outside.
    I use a QSqlRelationalTableModel frequently calling select() to refresh the actual database data.
    The Model is connected To a QDataWidgetMapper who has several QLabels mapped to.
    The datafields are displayed correctly but they don't refresh, when data changes from outside.


    A QTableView, connected to the Model, displays the refreshed data, but the labels don't.
    Qt Code:
    1. m_pModel = new QSqlRelationalTableModel(this);
    2.  
    3. m_pModel->setTable("Auftraege");
    4. m_pModel->setSort(DB_AUFTRAG_ID, Qt::AscendingOrder);
    5. m_pModel->setRelation(DB_AUFTRAG_KUNDENNUMMER, QSqlRelation("Kunde", 0, "ORT"));
    6. m_pModel->select();
    7.  
    8. m_pMapper = new QDataWidgetMapper(this);
    9. m_pMapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
    10. m_pMapper->setModel(m_pModel);
    11. //m_pMapper->setItemDelegate(new QSqlRelationalDelegate(this));
    12. m_pMapper->addMapping(ui->m_lbTaskNr, DB_AUFTRAG_NUMMER, "text");
    13. m_pMapper->addMapping(ui->m_lbName1, DB_AUFTRAG_KUNDENNAME1, "text");
    14.  
    15.  
    16. void MASK_AUFTRAG_HAUPT::vRefreshFromDB()
    17. {
    18. m_pModel->select();
    19. m_pMapper->revert(); //doesn't work, why?
    20. }
    To copy to clipboard, switch view to plain text mode 

    is there a way to provide frequently refreshing, using a QDataWidgetMapper?

  2. #2
    Join Date
    Dec 2013
    Posts
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Monitoring changing data of a database via QSqlRelationalmodel and QDatawidgetMap

    doesn't anyone have an idea?

    when I close the form and reopen it, the widgets show the actual values of the database, but I couldn manage to refresh the open form frequently, when the database values are changing from outside!

Similar Threads

  1. Concurrent database access and QDataWidgetMapper?
    By cyberduck in forum Qt Programming
    Replies: 2
    Last Post: 10th December 2013, 10:25
  2. Adding new record to database from QDataWidgetMapper
    By naptizaN in forum Qt Programming
    Replies: 4
    Last Post: 15th July 2012, 13:19
  3. Replies: 0
    Last Post: 25th June 2011, 18:01
  4. Replies: 3
    Last Post: 4th August 2010, 18:51
  5. Replies: 3
    Last Post: 21st January 2008, 12:22

Tags for this Thread

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.