|
1 | NO CONTENT: new file 100644, binary diff hidden |
@@ -5,7 +5,7 | |||
|
5 | 5 | |
|
6 | 6 | This example shows how to use QAbstractItemModel derived model as the data for the series. |
|
7 | 7 | |
|
8 | \image modeldata.png | |
|
8 | \image examples_modeldata.png | |
|
9 | 9 | |
|
10 | 10 | Let's start by creating an instance of CustomTableModel class. |
|
11 | 11 | CustomTableModel class is derived from QAbstractTableModel and it was created for the purpose of this example. |
@@ -14,7 +14,7 | |||
|
14 | 14 | \snippet ../examples/modeldata/tablewidget.cpp 1 |
|
15 | 15 | |
|
16 | 16 | We now have a model with data that we would like to display both on the chart and in a QTableView. |
|
17 | First, we create QTableView and tell it use the model as a data source. | |
|
17 | First, we create QTableView and tell it use the model as a data source. To make the data cells fill the table view we also change headers resize mode. | |
|
18 | 18 | |
|
19 | 19 | \snippet ../examples/modeldata/tablewidget.cpp 2 |
|
20 | 20 |
@@ -25,6 +25,7 | |||
|
25 | 25 | #include <QChart> |
|
26 | 26 | #include <QChartView> |
|
27 | 27 | #include <QLineSeries> |
|
28 | #include <QHeaderView> | |
|
28 | 29 | |
|
29 | 30 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
30 | 31 | |
@@ -41,11 +42,9 TableWidget::TableWidget(QWidget *parent) | |||
|
41 | 42 | // create table view and add model to it |
|
42 | 43 | QTableView *tableView = new QTableView; |
|
43 | 44 | tableView->setModel(model); |
|
45 | tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch); | |
|
46 | tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch); | |
|
44 | 47 | //! [2] |
|
45 | tableView->setColumnWidth(0, 56); | |
|
46 | tableView->setColumnWidth(1, 56); | |
|
47 | tableView->setColumnWidth(2, 56); | |
|
48 | tableView->setColumnWidth(3, 56); | |
|
49 | 48 | |
|
50 | 49 | //! [3] |
|
51 | 50 | QChart *chart = new QChart; |
|
1 | NO CONTENT: file was removed, binary diff hidden |
General Comments 0
You need to be logged in to leave comments.
Login now