diff --git a/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp b/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp
index 5d7fa72875f65852377cd08f90b8f1aa9543d433..2881513ab685076e537f7c97eebabc5b7e8eca33 100644
--- a/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp
+++ b/share/qtcreator/templates/wizards/classes/itemmodel/listmodel.cpp
@@ -28,7 +28,7 @@ bool %{CN}::setHeaderData(int section, Qt::Orientation orientation, const QVaria
 
 int %{CN}::rowCount(const QModelIndex &parent) const
 {
-    if (!parent.isValid())
+    if (parent.isValid())
         return 0;
 
     // FIXME: Implement me!
diff --git a/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp b/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp
index fb452feace5f5a27381edb839c6e0e1ed58b3e47..80bedf5899012de8bf75a4bf4c5979d5fd64c3ec 100644
--- a/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp
+++ b/share/qtcreator/templates/wizards/classes/itemmodel/tablemodel.cpp
@@ -29,7 +29,7 @@ bool %{CN}::setHeaderData(int section, Qt::Orientation orientation, const QVaria
 
 int %{CN}::rowCount(const QModelIndex &parent) const
 {
-    if (!parent.isValid())
+    if (parent.isValid())
         return 0;
 
     // FIXME: Implement me!
@@ -37,7 +37,7 @@ int %{CN}::rowCount(const QModelIndex &parent) const
 
 int %{CN}::columnCount(const QModelIndex &parent) const
 {
-    if (!parent.isValid())
+    if (parent.isValid())
         return 0;
 
     // FIXME: Implement me!