Results 1 to 4 of 4

Thread: QSqlQueryModel edit table & direct query to the database

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2009
    Posts
    75
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    15

    Default Re: QSqlQueryModel edit table & direct query to the database

    Thanks!
    That what I'm saing!


    Allmost

    I'ld like to excecute any query, so I've:
    Qt Code:
    1. model = new EditableSqlModel;
    2. model->setQuery("SELECT ID_t, ID_podmiot, ID_oddzial, Numer, Numer_zleceniodawcy FROM m_transporty LIMIT 0 , 30");
    To copy to clipboard, switch view to plain text mode 
    but in example there is:

    Qt Code:
    1. void EditableSqlModel::refresh()
    2. {
    3. setQuery("select * from person");
    4. setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
    5. setHeaderData(1, Qt::Horizontal, QObject::tr("First name"));
    6. setHeaderData(2, Qt::Horizontal, QObject::tr("Last name"));
    7. }
    To copy to clipboard, switch view to plain text mode 

    I'd like to change query in setQuery automatyicly. I've tried use to
    Qt Code:
    1. setQuery(this->query().executedQuery());
    To copy to clipboard, switch view to plain text mode 
    but it's empty
    Last edited by TomASS; 2nd October 2011 at 14:02.

  2. #2
    Join Date
    Feb 2011
    Location
    Romania
    Posts
    53
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1
    Thanked 11 Times in 9 Posts

    Default Re: QSqlQueryModel edit table & direct query to the database

    Quote Originally Posted by TomASS View Post
    I'd like to change query in setQuery automatyicly.
    Can you be a little more explicit? If you need to change query in model view, you will always have to call
    Qt Code:
    1. QSqlQueryModel::setQuery
    To copy to clipboard, switch view to plain text mode 
    (and also to set header data in model)

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

    TomASS (3rd October 2011)

Similar Threads

  1. Edit table for my own table-widget
    By MasterMatrix in forum Qt Programming
    Replies: 0
    Last Post: 1st December 2010, 07:05
  2. Replies: 5
    Last Post: 3rd April 2010, 04:07
  3. QSqlite database lock + Delegate + QSqlQueryModel
    By NoRulez in forum Qt Programming
    Replies: 0
    Last Post: 13th October 2009, 11:52
  4. Replies: 1
    Last Post: 26th March 2009, 15:25
  5. View/edit database in a table and in a form
    By igorko in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2006, 09:09

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
  •  
Qt is a trademark of The Qt Company.