diff options
Diffstat (limited to 'examples/widgets/tutorials/modelview/4_headers/mymodel.cpp')
-rw-r--r-- | examples/widgets/tutorials/modelview/4_headers/mymodel.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/examples/widgets/tutorials/modelview/4_headers/mymodel.cpp b/examples/widgets/tutorials/modelview/4_headers/mymodel.cpp index 35e3463b7f..0084475374 100644 --- a/examples/widgets/tutorials/modelview/4_headers/mymodel.cpp +++ b/examples/widgets/tutorials/modelview/4_headers/mymodel.cpp @@ -51,7 +51,7 @@ #include "mymodel.h" MyModel::MyModel(QObject *parent) - :QAbstractTableModel(parent) + : QAbstractTableModel(parent) { } @@ -70,8 +70,7 @@ int MyModel::columnCount(const QModelIndex & /*parent*/) const //------------------------------------------------------- QVariant MyModel::data(const QModelIndex &index, int role) const { - if (role == Qt::DisplayRole) - { + if (role == Qt::DisplayRole) { return QString("Row%1, Column%2") .arg(index.row() + 1) .arg(index.column() +1); @@ -82,18 +81,14 @@ QVariant MyModel::data(const QModelIndex &index, int role) const //! [quoting mymodel_c] QVariant MyModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (role == Qt::DisplayRole) - { - if (orientation == Qt::Horizontal) { - switch (section) - { - case 0: - return QString("first"); - case 1: - return QString("second"); - case 2: - return QString("third"); - } + if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { + switch (section) { + case 0: + return QString("first"); + case 1: + return QString("second"); + case 2: + return QString("third"); } } return QVariant(); |