diff --git a/modules/gui/src/python_shell/python_syntax_highlighter.cc b/modules/gui/src/python_shell/python_syntax_highlighter.cc
index f37eb4d61f866bd097ad8ddfbbce68fa565b23aa..c4488112db908a4c98091393eec87c89d46fa29e 100644
--- a/modules/gui/src/python_shell/python_syntax_highlighter.cc
+++ b/modules/gui/src/python_shell/python_syntax_highlighter.cc
@@ -86,7 +86,9 @@ void PythonSyntaxHighlighter::highlightBlock(const QString& text_block) {
   } else if (currentBlockState() & BLOCKTYPE_CODE) {
     base_state=BLOCKTYPE_CODE;
   }
+#if QT_VERSION < 0x040700
   cursor.setBlockFormat(block_formats_[static_cast<BlockType>(base_state)]);
+#endif
   if (currentBlockState() & BLOCKTYPE_BLOCKEDIT || 
       currentBlockState() & BLOCKTYPE_ACTIVE || 
       currentBlockState() & BLOCKTYPE_CODE) {