##// END OF EJS Templates
Improved modelData example visual appearance
Marek Rosa -
r1030:5594c69cffa0
parent child
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -5,7 +5,7
5
5
6 This example shows how to use QAbstractItemModel derived model as the data for the series.
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 Let's start by creating an instance of CustomTableModel class.
10 Let's start by creating an instance of CustomTableModel class.
11 CustomTableModel class is derived from QAbstractTableModel and it was created for the purpose of this example.
11 CustomTableModel class is derived from QAbstractTableModel and it was created for the purpose of this example.
@@ -14,7 +14,7
14 \snippet ../examples/modeldata/tablewidget.cpp 1
14 \snippet ../examples/modeldata/tablewidget.cpp 1
15
15
16 We now have a model with data that we would like to display both on the chart and in a QTableView.
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 \snippet ../examples/modeldata/tablewidget.cpp 2
19 \snippet ../examples/modeldata/tablewidget.cpp 2
20
20
@@ -25,6 +25,7
25 #include <QChart>
25 #include <QChart>
26 #include <QChartView>
26 #include <QChartView>
27 #include <QLineSeries>
27 #include <QLineSeries>
28 #include <QHeaderView>
28
29
29 QTCOMMERCIALCHART_USE_NAMESPACE
30 QTCOMMERCIALCHART_USE_NAMESPACE
30
31
@@ -41,11 +42,9 TableWidget::TableWidget(QWidget *parent)
41 // create table view and add model to it
42 // create table view and add model to it
42 QTableView *tableView = new QTableView;
43 QTableView *tableView = new QTableView;
43 tableView->setModel(model);
44 tableView->setModel(model);
45 tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
46 tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch);
44 //! [2]
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 //! [3]
49 //! [3]
51 QChart *chart = new QChart;
50 QChart *chart = new QChart;
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now