Results 1 to 3 of 3

Thread: Problem with QTableView

  1. #1
    Join Date
    Nov 2008
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question Problem with QTableView

    Hello,
    I am from brazil.

    i am with a problem on the QTableView, when i put a model of the a Connection, not refresh...

    code:

    QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");

    db.setHostName("localhost");
    db.setDatabaseName("alan");
    db.setUserName("postgres");
    db.setPassword("351321");
    bool ok = db.open();

    QSqlTableModel *model = new QSqlTableModel(this,db);
    model->setTable("tbproduto");
    model->select();
    model->setHeaderData(0, Qt::Horizontal, QObject::tr("Codigo do Produto"));
    model->setHeaderData(1, Qt::Horizontal, QObject::tr("Produto"));

    ui.Grade->setModel(model);
    ui.Grade->show();

    ...

  2. #2
    Join Date
    Nov 2008
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Problem with QTableView

    you understand?
    how i can update the QTableView?

  3. #3
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem with QTableView

    To be honest: no, I do not understand your problem.
    Do you want the QSqlTableModel to track changes in the database so your view always show the "live" state and updates as modifications are made?

    If yes:
    bad luck. you will need to peridically (QTimer)call select() to refresh the contents of the model.
    (As far as I know Qt does not support databases that push changes to clients. I might be wrong, though.)

    Was that your question?

Similar Threads

  1. Problem on Resizing of QTableView colums ?
    By rajeshs in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2008, 04:03
  2. Problem with QTableView
    By BoneCollector in forum Qt Programming
    Replies: 5
    Last Post: 12th March 2008, 12:30
  3. Slow problem QTableView
    By skuda in forum Qt Programming
    Replies: 6
    Last Post: 26th February 2008, 12:19
  4. problem in printing QTableView
    By miguel_mark in forum Qt Programming
    Replies: 2
    Last Post: 6th February 2008, 08:19
  5. Problem: QThead and QTableview
    By ederbs in forum Qt Programming
    Replies: 5
    Last Post: 9th November 2007, 10:17

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.