##// END OF EJS Templates
BarModelMapper example updated
Marek Rosa -
r1393:be0ddde2e42e
parent child
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -5,6 +5,8
5
5
6 This example shows how to use QAbstractItemModel derived model as the data for the bar series.
6 This example shows how to use QAbstractItemModel derived model as the data for the bar series.
7
7
8 \image examples_barmodelmapper.png
9
8 Let's start by creating an instance of CustomTableModel class.
10 Let's start by creating an instance of CustomTableModel class.
9 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.
10 The constructor of this class populates the internal data store of the model with the data that is good for our chart example.
12 The constructor of this class populates the internal data store of the model with the data that is good for our chart example.
@@ -12,7 +14,7
12 \snippet ../examples/barmodelmapper/tablewidget.cpp 1
14 \snippet ../examples/barmodelmapper/tablewidget.cpp 1
13
15
14 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.
15 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.
17 First, we create QTableView and tell it use the model as a data source. To have the data presented nicely the minimum width of the table view is set and its headers resize mode changed to stretch.
16
18
17 \snippet ../examples/barmodelmapper/tablewidget.cpp 2
19 \snippet ../examples/barmodelmapper/tablewidget.cpp 2
18
20
@@ -46,7 +46,8 TableWidget::TableWidget(QWidget *parent)
46 // create table view and add model to it
46 // create table view and add model to it
47 QTableView *tableView = new QTableView;
47 QTableView *tableView = new QTableView;
48 tableView->setModel(model);
48 tableView->setModel(model);
49 tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
49 tableView->setMinimumWidth(300);
50 tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
50 tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch);
51 tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch);
51 //! [2]
52 //! [2]
52
53
General Comments 0
You need to be logged in to leave comments. Login now