Results 1 to 4 of 4

Thread: Not corect record pos in data table after update

  1. #1
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Not corect record pos in data table after update

    Ok i 'll try explain it

    I have data table (read only). I fill it through QSqlSelectCursor.When i catch double click on data table row i create widget for editing(there i use QSqlForm for relate table fields with controls).After i finish edit my edited record move at last row in data table

    Is that correct? I dont think that...Give piece of code

    Qt Code:
    1. // reaction on double click catching,dtMain - pointer on my data table
    2. QFormUpdBranch frmUpdBranch(dtMain,false);
    3. frmAddBranch.exec();
    4.  
    5. // constructor of QFormUpdBranch
    6. QSqlRecord *recordSelected = m_pdtMain->currentRecord();
    7. int nBranchId = recordSelected->value("id").toInt();
    8. m_pcurUpdate = new QSqlCursor("branches");
    9. m_pcurUpdate->select("id = " + QString::number(nBranchId));
    10. m_pcurUpdate->next();
    11.  
    12. m_psqlForm = new QSqlForm(this);
    13. m_psqlForm->setRecord(m_pcurUpdate->primeUpdate());
    14. m_psqlForm->insert(txtBranchName, "description");
    15. m_psqlForm->insert(txtIP, "ip_address");
    16. m_psqlForm->insert(txtPort, "port");
    17. m_psqlForm->readFields();
    18.  
    19. // reaction on Ok
    20. m_psqlForm->writeFields();
    21. m_pcurUpdate->update();
    22. m_pdtMain->refresh(QDataTable::RefreshAll);
    To copy to clipboard, switch view to plain text mode 

    Hope for your help..
    a life without programming is like an empty bottle

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Not corect record pos in data table after update

    Quote Originally Posted by zlatko
    m_pdtMain->refresh(QDataTable::RefreshAll);
    Simple "m_pdtMain->refresh()" should be enough.

    How do you sort that table? Did you use ORDER BY clause?

  3. The following user says thank you to jacek for this useful post:

    zlatko (2nd May 2006)

  4. #3
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Not corect record pos in data table after update

    Quote Originally Posted by jacek
    Simple "m_pdtMain->refresh()" should be enough.

    How do you sort that table? Did you use ORDER BY clause?
    No I havent use sorting
    a life without programming is like an empty bottle

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Not corect record pos in data table after update

    Quote Originally Posted by zlatko
    No I havent use sorting
    In that case records can be in any order.

Similar Threads

  1. QSqlQueryModel data update
    By psi in forum Qt Programming
    Replies: 4
    Last Post: 20th July 2012, 03:59
  2. Replies: 3
    Last Post: 5th October 2008, 23:41
  3. Record update windowd entered data saving
    By MarkoSan in forum Qt Programming
    Replies: 56
    Last Post: 18th January 2006, 18:50

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.