summaryrefslogtreecommitdiff
path: root/examples/tutorials/modelview/1_readonly/mymodel.cpp
diff options
context:
space:
mode:
authorMichael D Scull <ext-michael.scull@nokia.com>2010-05-27 15:12:58 +0200
committerDavid Boddie <dboddie@trolltech.com>2010-07-07 17:07:53 +0200
commitf574700f920ae5d5bda25ba217d6face9f3d3902 (patch)
treea4db1390147f7b6041ca763be6715078b1ddd9ab /examples/tutorials/modelview/1_readonly/mymodel.cpp
parent4df3fb13821e13ecf581d87f2d224b2f1b964609 (diff)
downloadqt4-tools-f574700f920ae5d5bda25ba217d6face9f3d3902.tar.gz
Rolands ModelView Source
Diffstat (limited to 'examples/tutorials/modelview/1_readonly/mymodel.cpp')
-rwxr-xr-xexamples/tutorials/modelview/1_readonly/mymodel.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/tutorials/modelview/1_readonly/mymodel.cpp b/examples/tutorials/modelview/1_readonly/mymodel.cpp
new file mode 100755
index 0000000000..ff3e2d208f
--- /dev/null
+++ b/examples/tutorials/modelview/1_readonly/mymodel.cpp
@@ -0,0 +1,30 @@
+#include "mymodel.h"
+
+MyModel::MyModel(QObject *parent)
+ :QAbstractTableModel(parent)
+{
+}
+
+//-------------------------------------------------------
+int MyModel::rowCount(const QModelIndex & /*parent*/ ) const
+{
+ return 2;
+}
+
+//-------------------------------------------------------
+int MyModel::columnCount(const QModelIndex & /*parent*/ ) const
+{
+ return 3;
+}
+
+//-------------------------------------------------------
+QVariant MyModel::data(const QModelIndex &index, int role ) const
+{
+ if(role == Qt::DisplayRole)
+ {
+ return QString("Row%1, Column%2")
+ .arg(index.row() + 1)
+ .arg(index.column() +1);
+ }
+ return QVariant();
+}