Home > Mobile >  QT small white tears for help.
QT small white tears for help.

Time:10-13

Learn a week of qt, implement a small project now encountered a problem of a long afternoon, is the only show in the tableview header data (headers and database content), but on the surface of the table does not display the content, how to solve?
As shown in figure

This is the inside of the database data

This is code section


Ps: in addition to the CPP file, I also carried out in login CPP file database connections, but when switching to the interface, I shut down the database connection, and then reconnect the database, don't know if there is problem,

CodePudding user response:

QSqlTableModel * pModel=new QSqlTableModel (this, _db);
You'll have no Model and the database binding

CodePudding user response:

reference 1/f, walk every step response:
QSqlTableModel * pModel=new QSqlTableModel (this, _db);
You'll have no Model and the database binding

After changed, or not to display, I have withered

CodePudding user response:

Mode - & gt; The select ()? This is a virtual function, the need to achieve,

CodePudding user response:

Your problem here because you bind only the table, but you did not query any data, so only the header,

CodePudding user response:

The model - & gt; SetFilter this interface to try,

CodePudding user response:

reference 5 floor hzh_Beyond reply:
model - & gt; Try setFilter this interface,

Thank you very much reply, I went back to try,

CodePudding user response:

Suggest you open the database in the main function, then the entire program, rather than every time need to open the database, very waste, your code should do not have what problem, I also am such,
  •  Tags:  
  • Qt
  • Related