[ fromfile: database.xml id: dbmodels ]
Figure 18.2 shows the concrete model classes for connecting to a QTableView.
If you want to show a table that was created after calling Example 18.4, it takes five lines of code with the QSqlTableModel.
Example 18.7. src/libs/tests/testsqlmetadata/testsqlmetadata.cpp
[ . . . . ] void TestSqlMetaData::showTable() { QSqlTableModel model; model.setTable("MetaData"); model.select(); QTableView *view = new QTableView; view->setModel(&model); view->setItemDelegate(new SimpleDelegate(view));
The testcase, excerpted in Example 18.7 scans a directory of your choice, as set by an environment variable,
TESTTRACKS
, and adds metadata for each mp3 file found to the table model.
It is included in the source tarball in from dist.
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |