diff --git a/plugins/itemfakevim/fakevim/fakevimhandler.cpp b/plugins/itemfakevim/fakevim/fakevimhandler.cpp
index 9d0cecc3bbc13d768496e4bd5ddbcf0e836149d7..218c3c2dc6fc2b92691e73ad5d20d2510827c035 100644
--- a/plugins/itemfakevim/fakevim/fakevimhandler.cpp
+++ b/plugins/itemfakevim/fakevim/fakevimhandler.cpp
@@ -104,6 +104,10 @@
 #   define UNDO_DEBUG(s)
 #endif
 
+#if QT_VERSION < QT_VERSION_CHECK(5,10,0)
+using QStringView = QStringRef;
+#endif
+
 namespace FakeVim {
 namespace Internal {
 
@@ -1510,7 +1514,11 @@ public:
         m_buffer = s; m_pos = m_userPos = pos; m_anchor = anchor >= 0 ? anchor : pos;
     }
 
+#if QT_VERSION < QT_VERSION_CHECK(5,10,0)
+    QStringRef userContents() const { return QStringRef(&m_buffer).left(m_userPos); }
+#else
     QStringView userContents() const { return QStringView{m_buffer}.left(m_userPos); }
+#endif
     const QChar &prompt() const { return m_prompt; }
     const QString &contents() const { return m_buffer; }
     bool isEmpty() const { return m_buffer.isEmpty(); }
@@ -2833,9 +2841,17 @@ void FakeVimHandler::Private::updateEditor()
 
 void FakeVimHandler::Private::setTabSize(int tabSize)
 {
+#if QT_VERSION >= QT_VERSION_CHECK(5,11,0)
     const int charWidth = QFontMetrics(EDITOR(font())).horizontalAdvance(' ');
+#else
+    const int charWidth = QFontMetrics(EDITOR(font())).width(' ');
+#endif
     const int width = charWidth * tabSize;
+#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
     EDITOR(setTabStopDistance(width));
+#else
+    EDITOR(setTabStopWidth(width));
+#endif
 }
 
 void FakeVimHandler::Private::restoreWidget(int tabSize)
diff --git a/plugins/itemfakevim/fakevim/utils/optional.h b/plugins/itemfakevim/fakevim/utils/optional.h
index 9450b308ede2422bd53bfa34b6225de31bf5e796..a89e6cec865bd218dc70ecafd40c8c91cd360312 100644
--- a/plugins/itemfakevim/fakevim/utils/optional.h
+++ b/plugins/itemfakevim/fakevim/utils/optional.h
@@ -35,7 +35,7 @@
 // std::optional from Apple's Clang supports methods that throw std::bad_optional_access only
 // with deployment target >= macOS 10.14
 // TODO: Use std::optional everywhere when we can require macOS 10.14
-#if !defined(__apple_build_version__)
+#if !defined(__apple_build_version__) && __cpp_lib_optional >= 201603
 
 #include <optional>
 
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 0d84cb05789c65e39e47b2b276b6e4fa89fc5153..740b695c9e55c2a322479193c12f91d0718e8d08 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -63,7 +63,11 @@ QPalette::ColorRole defaultColorVarToRole(const QString &varName)
     static QHash<QString, QPalette::ColorRole> map = {
         {defaultColorVarBase, QPalette::Base},
         {defaultColorVarText, QPalette::Text},
+#if QT_VERSION >= QT_VERSION_CHECK(5,12,0)
         {defaultColorVarPlaceholderText, QPalette::PlaceholderText},
+#else
+        {defaultColorVarPlaceholderText, QPalette::AlternateBase},
+#endif
         {defaultColorVarAlternateBase, QPalette::AlternateBase},
         {defaultColorVarHighlight, QPalette::Highlight},
         {defaultColorVarHighlightText, QPalette::HighlightedText},