summaryrefslogtreecommitdiffstats
path: root/examples/widgets/tutorials/modelview/4_headers/mymodel.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-11-13 01:00:13 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-11-13 01:00:13 +0100
commit0441d959ff87431ab432ce0c30bbb857a631742e (patch)
tree25c6c4293f74e39b9d4cf45b15957f233cffa9c5 /examples/widgets/tutorials/modelview/4_headers/mymodel.cpp
parentae0dd3201bc13b81c62752bb04e42362c78bfe16 (diff)
parent8c685b765bf4ceba3c4cf8fdd9c9d680f338b7a9 (diff)
Merge remote-tracking branch 'origin/5.12' into dev
Diffstat (limited to 'examples/widgets/tutorials/modelview/4_headers/mymodel.cpp')
-rw-r--r--examples/widgets/tutorials/modelview/4_headers/mymodel.cpp25
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();