Customor: : customor (QWidget * parent) :
QWidget (parent),
UI (new UI: : customor)
{
The UI - & gt; SetupUi (this);
The model=new QSqlTableModel (this);
The model - & gt; SetTable (" Press ");
The model - & gt; The select ();
The UI - & gt; Baokantableview - & gt; SetModel (model);
}
Set in the constructor, so that we can display properly, double-click the TableView can directly edit content
But using a write their own search function, double-click the TableView can't edit the
Void customor: : find ()
{
QSqlQueryModel * modell=new QSqlQueryModel;
QString find sql0;
The find=UI - & gt; LineEdit - & gt; The text ();
Sql0="select * from Press where names LIKE '%" + find + "%'";
Modell - & gt; SetQuery (sql0);
The UI - & gt; Baokantableview - & gt; SetModel (modell);
}
Before I search can edit
Search after the double-click will not be able to edit the
??????????/
CodePudding user response:
Up and down is not the same as the modelCodePudding user response:
The former is: QSqlTableModel, the latter is: QSqlQueryModel