Results 1 to 4 of 4

Thread: Access to QSqlTableModel::isDirty Question.

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Access to QSqlTableModel::isDirty Question.

    I have write a QTableView to edit all mysql table wo having index... ++ limit row
    now i use model->setEditStrategy(QSqlTableModel::OnManualSubmit) ;

    Question how i cann access to http://doc.trolltech.com/4.0/qsqltab...l.html#isDirty to
    make question to save submit?



    Qt Code:
    1. /* discovery total row whitout limit mysql / to play next prev ... button */
    2. void Search_on_Table::UpdateSumm()
    3. {
    4. QString grepprimary,grepauto;
    5. /* reset index fieldname */
    6. /* SHOW INDEX FROM USER_ASSO_0 */
    7. INDEXFIELD = "";
    8. FieldNameList.clear();
    9. const QString info = QString("SHOW COLUMNS FROM %1").arg(table);
    10. QSqlQuery query(info,db);
    11. QSqlRecord rec = query.record();
    12. ////int sumcol = rec.count();
    13. while (query.next()) {
    14. grepprimary = query.value(3).toString();
    15. grepprimary = grepprimary.toLower();
    16. grepauto = query.value(5).toString();
    17. grepauto = grepauto.toLower();
    18. Q_ASSERT(grepauto.size() > 1); /* no mysql or not connect! or grand not...*/
    19. if (grepprimary == "pri" && grepauto.contains("auto")) {
    20. INDEXFIELD = query.value(0).toString();
    21. qDebug() << "### INDEXFIELD have found " << INDEXFIELD;
    22. }
    23. FieldNameList.append(query.value(0).toString());
    24. }
    25. totfield = FieldNameList.size();
    26. if (INDEXFIELD.size() < 1) {
    27. haveindex = false;
    28. } else {
    29. haveindex = true;
    30. }
    31. totalrow = 0;
    32. if (haveindex) {
    33. const QString summitem = QString("SELECT COUNT(%2) FROM %1").arg(table).arg(INDEXFIELD);
    34. query.exec(summitem);
    35. while (query.next()) {
    36. totalrow = query.value(0).toInt();
    37. }
    38. label_3->setText(tr("Name: %1 Tot.Row: %2 Index: %3").arg(table).arg(totalrow).arg(INDEXFIELD));
    39. } else {
    40. SqlError(false);
    41. label_3->setText(tr("Name: %1 Not having index!").arg(table));
    42. }
    43. //////qDebug() << "### totalrow " << totalrow;
    44. }
    45.  
    46. void Search_on_Table::initializeModel( int limitrow )
    47. {
    48. model->setFilter(QString("1 LIMIT %1, %2").arg(status).arg(limitrow));
    49. if (INDEXFIELD.size() > 0) {
    50. for (int i = 0; i < FieldNameList.size(); ++i) {
    51. const QString af = FieldNameList.at(i);
    52. if (af == INDEXFIELD) {
    53. model->setHeaderData(i, Qt::Horizontal, tr("ID/%1").arg(INDEXFIELD));
    54. } else {
    55. model->setHeaderData(i, Qt::Horizontal,af);
    56. }
    57. }
    58. }
    59. SqlError(model->select()); /* pixmap-label green/red */
    60. if (haveindex) {
    61. model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    62. }
    63. tableView->setModel(model);
    64. label_4->setText(tr("Status %1 - %2").arg(status).arg(limitrow));
    65. PaintButton(); /* button enable or disable next prev */
    66. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Access to QSqlTableModel::isDirty Question.

    What do you mean "how to access" it? Can't you just call it for the index you're interested in?

  3. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Access to QSqlTableModel::isDirty Question.

    Quote Originally Posted by wysota View Post
    What do you mean "how to access" it? Can't you just call it for the index you're interested in?
    how connect a wake up to QModelIndex

    connect(tableView, SIGNAL(activated(QModelIndex)), this, SLOT(WakeUpTable(QModelIndex)));
    connect(tableView, SIGNAL(entered(QModelIndex)), this, SLOT(WakeUpTable(QModelIndex)));

    model connect not run .... all other button run ..


    not run....

    to write a WakeUpTable( QModelIndex index )
    bool QSqlTableModel::isDirty ( const QModelIndex & index ) const

    I like only to know the area wo user update ... to tell question ..... on closeevent( e)
    you like save if isDirty is true....?

  4. #4
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Access to QSqlTableModel::isDirty Question.

    i found ...

    Qt Code:
    1. connect(tableView->model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(WakeUpTable(QModelIndex)));
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. ODBC and MS Access
    By allensr in forum Qt Programming
    Replies: 2
    Last Post: 10th April 2007, 23:41
  2. Question regarding how to paint after zoom.
    By JonathanForQT4 in forum Qt Programming
    Replies: 2
    Last Post: 26th January 2007, 15:34
  3. Replies: 1
    Last Post: 4th October 2006, 16:05
  4. Replies: 5
    Last Post: 14th July 2006, 22:42
  5. inserting string > 127 characters to MS Access
    By jh in forum Qt Programming
    Replies: 0
    Last Post: 12th May 2006, 17:11

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.