Results 1 to 7 of 7

Thread: mapper stop after upgrade to 4.4.3

  1. #1
    Join Date
    Jul 2008
    Posts
    69
    Thanks
    9
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default mapper stop after upgrade to 4.4.3

    I have upgraded QT from 4.4.0 to the latest 4.4.3(of Nokia)

    and the QDataWidgetMapper doesn't seem to work anymore!!

    is anybody had similar pb??
    or is it that my code is missing something which only work with the previous version?

    I load the database to display a list in the table "ui.tableView_PL" (this still work and display the table).
    and I use mapper to show some info into different labels. but nothing is display on these labals anymore.

    It worked before the upgrade so I am a bit puzzled...

    Qt Code:
    1. void mainwindow::loadProgamListFromDB(QString indexPL, bool addnewElement) {
    2.  
    3.  
    4. // loAD table
    5. QSqlQueryModel *modelFromSql = new QSqlQueryModel();
    6. QString sqlString =
    7. "SELECT id,name, capacity,duration, position FROM plandfile WHERE pl_id="
    8. + indexPL + " ORDER BY position";//ORDER BY id ASC ";
    9. modelFromSql->setQuery(sqlString);
    10. ui.tableView_PL->setModel(modelFromSql);
    11. modelFromSql->setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
    12. modelFromSql->setHeaderData(1, Qt::Horizontal, QObject::tr("Name"));
    13. modelFromSql->setHeaderData(2, Qt::Horizontal, QObject::tr("Capacity"));
    14. modelFromSql->setHeaderData(3, Qt::Horizontal, QObject::tr("Duration"));
    15. modelFromSql->setHeaderData(4, Qt::Horizontal, QObject::tr("Position"));
    16.  
    17. ui.tableView_PL->show();
    18.  
    19. int numberofvalues = modelFromSql->rowCount();
    20. if (addnewElement) {
    21. selectedRowIndex = (numberofvalues - 1);//row to be highlighted // when add Pause selected row should last row
    22. }
    23. ui.tableView_PL->selectRow(selectedRowIndex);//row to be highlighted
    24.  
    25. //sizes of the columns
    26. ui.tableView_PL->setColumnWidth(0, 40);//size for index
    27. ui.tableView_PL->setColumnWidth(1, 300);//size for name
    28. ui.tableView_PL->setColumnWidth(4, 50);//size for position
    29. ui.tableView_PL->hideColumn(4);//hide position column
    30. ui.tableView_PL->hideColumn(0);//hide index column
    31.  
    32. ui.tableView_PL->setFocus();
    33.  
    34. QString message=" numberofvalues: "+QString::number(numberofvalues,10)
    35. +" selectedRowIndex: "+QString::number(selectedRowIndex,10);
    36. QMessageBox::about(this, tr("numberofvalues"), message);// need <QtGui>
    37.  
    38. QDataWidgetMapper *mapper = new QDataWidgetMapper(this);
    39. mapper->setModel(modelFromSql);
    40. mapper->setItemDelegate(new QSqlRelationalDelegate(this));
    41. mapper->addMapping(ui.label_plandfileID, 0);//map label3 to the first column
    42. mapper->addMapping(ui.label_plandfileName, 1);
    43. mapper->addMapping(ui.label_position, 4);
    44.  
    45. mapper->setCurrentIndex(selectedRowIndex);
    46.  
    47. connect(ui.tableView_PL->selectionModel(), SIGNAL(currentRowChanged (QModelIndex,QModelIndex)), mapper, SLOT(setCurrentModelIndex(QModelIndex)));
    48. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: mapper stop after upgrade to 4.4.3

    Hi,

    RelationalDelegate on a QueryModel - does that work? Another idea try mapper->toFirst() after addMapping.

  3. #3
    Join Date
    Jul 2008
    Posts
    69
    Thanks
    9
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mapper stop after upgrade to 4.4.3

    I ve tried mapper-> tofirst(); but still nothing

    RelationalDelegate on a QueryModel - does that work?
    It did with 4.4.0 , I may have to try with another model type...

  4. #4
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: mapper stop after upgrade to 4.4.3

    Hi,

    but how does the RelationalDelegate know to resolve the foreignkey with a QueryModel?

    Afaik it should then be something like this:

    Qt Code:
    1. mapper->setModel(MyQSqlRelationalTableModel->relationModel(int column));
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jul 2008
    Posts
    69
    Thanks
    9
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mapper stop after upgrade to 4.4.3

    I try many things but mapper doesn't seem to work anymore with 4.4.3

    came back with 4.4.0 . and... it s back to normal, working fine.


    anybody knows how to submit a bug to Nokia(QT)???

  6. #6
    Join Date
    Jul 2008
    Posts
    69
    Thanks
    9
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mapper stop after upgrade to 4.4.3

    I have check qt bug
    it seems that this happened to others as well.
    bug submitted but it is not a priority .
    i'll stay with QT4.4.0 for now, and upgrade later for next release

  7. #7
    Join Date
    Jul 2008
    Posts
    69
    Thanks
    9
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mapper stop after upgrade to 4.4.3

    I have fix my problem using this code instead

    Qt Code:
    1. void mainwndow::updateQlabel(const QModelIndex &index){
    2. //try to go around the QT bug
    3.  
    4. int row =index.row();
    5.  
    6. ui.label_toupdate->setText(modelFromSql->record(row).field("id").value().toString());
    To copy to clipboard, switch view to plain text mode 

    with "modelFromSql" a private member (QSqlQueryModel) declare in the .h
    and
    Qt Code:
    1. mainwndow::mainwndow(QWidget *parent) :
    2. QMainWindow(parent)
    3. ,modelFromSql()//to carry current table model
    4. {.......
    5. ...
    To copy to clipboard, switch view to plain text mode 

    I hope this help others

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.