I use SQLite 3.
in that database I have table
CREATE TABLE [languages] (
id INTEGER PRIMARY KEY AUTOINCREMENT,
language TEXT NOT NULL ,
used BOOL NOT NULL
);
CREATE TABLE [languages] (
id INTEGER PRIMARY KEY AUTOINCREMENT,
language TEXT NOT NULL ,
used BOOL NOT NULL
);
To copy to clipboard, switch view to plain text mode
I create new model and set that options
m_langugesTableModel->setTable("languages");
m_langugesTableModel
->setEditStrategy
(QSqlTableModel::OnManualSubmit);
res = m_langugesTableModel->select();
res = m_langugesTableModel->removeColumn(0);
res
= m_langugesTableModel
->setHeaderData
(0, Qt
::Horizontal,
QObject::tr("Language"));
res
= m_langugesTableModel
->setHeaderData
(1, Qt
::Horizontal,
QObject::tr("Enabled"));
m_langugesTableModel = new QSqlTableModel(NULL, database);
m_langugesTableModel->setTable("languages");
m_langugesTableModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
res = m_langugesTableModel->select();
res = m_langugesTableModel->removeColumn(0);
res = m_langugesTableModel->setHeaderData(0, Qt::Horizontal, QObject::tr("Language"));
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.
tv_languages->setModel(m_languagesTableModel);
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.
Bookmarks