Results 1 to 2 of 2

Thread: QTableView and SqlLite

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question QTableView and SqlLite

    I use SQLite 3.
    in that database I have table
    Qt Code:
    1. CREATE TABLE [languages] (
    2. id INTEGER PRIMARY KEY AUTOINCREMENT,
    3. language TEXT NOT NULL ,
    4. used BOOL NOT NULL
    5. );
    To copy to clipboard, switch view to plain text mode 

    I create new model and set that options
    Qt Code:
    1. m_langugesTableModel = new QSqlTableModel(NULL, database);
    2. m_langugesTableModel->setTable("languages");
    3. m_langugesTableModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
    4.  
    5. res = m_langugesTableModel->select();
    6. res = m_langugesTableModel->removeColumn(0);
    7. res = m_langugesTableModel->setHeaderData(0, Qt::Horizontal, QObject::tr("Language"));
    8. res = m_langugesTableModel->setHeaderData(1, Qt::Horizontal, QObject::tr("Enabled"));
    To copy to clipboard, switch view to plain text mode 

    than I create new QTableView and set model for that view.
    Qt Code:
    1. tv_languages->setModel(m_languagesTableModel);
    To copy to clipboard, switch view to plain text mode 

    I want to edit used field of database using QCheckBox, but if I create Delegate, than I don't now how create correct paint method for that delegate.
    If I create my own model, than CheckBox draw in one place, but to edit value I had to twice click near checkbox.

    I try use delegate and fags() method of my model, but than I got two checkboxes, when edit value.

    How can I get CheckBox in table view, than edit with one click?

    Please, help me to solve my problem.
    Last edited by Myrgy; 4th October 2009 at 13:38.

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.