diff --git a/PKGBUILD b/PKGBUILD
index 8a6b1582ee1ea886302ac44e0f3a46bf94c090cd..376ed9b3aaf511ffba591dba13a43476badf56df 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -7,7 +7,7 @@ pkgbase=qt5-base
 pkgname=(qt5-base qt5-xcb-private-headers)
 _qtver=5.10.1
 pkgver=${_qtver/-/}
-pkgrel=5
+pkgrel=6
 arch=(x86_64)
 url='http://qt-project.org/'
 license=('GPL3' 'LGPL3' 'FDL' 'custom')
@@ -30,11 +30,13 @@ _pkgfqn="${pkgbase/5-/}-everywhere-src-${_qtver}"
 source=("http://download.qt.io/official_releases/qt/${pkgver%.*}/${_qtver}/submodules/${_pkgfqn}.tar.xz"
 		"revert-Set-sharedPainter-correctly-for-QGraphicsEffect.patch"
 		"qtbug-65478.patch"
-		qheaderview-restore.patch::"https://code.qt.io/cgit/qt/qtbase.git/patch/?id=4a04eea4")
+		qheaderview-restore.patch::"https://code.qt.io/cgit/qt/qtbase.git/patch/?id=4a04eea4"
+		qtbug-66444.patch::"https://code.qt.io/cgit/qt/qtbase.git/patch/?id=9395f35c")
 sha256sums=('d8660e189caa5da5142d5894d328b61a4d3ee9750b76d61ad74e4eee8765a969'
             'e98cb66de308f85ef2d8e05062ada4d1ca4d88ebe836281489d5c0c9c2495a4b'
             '9afdfc018c3894f12e7a01a8221d9f7be9feba00902d98f0e6a09612b68b2619'
-            '3a1016cbf8c3c4676e6fc406756ffa5a151ffe09153dfc0fa7ed3c16945b0ae5')
+            '3a1016cbf8c3c4676e6fc406756ffa5a151ffe09153dfc0fa7ed3c16945b0ae5'
+            '88766a7b73a03e1219800c8fdc56afbf23b15d16cc61c4d77547b1fd2404ea6e')
 validpgpkeys=('6DD4217456569BA711566AC7F06E8FDE7B45DAAC') # Eric Vidal
 
 prepare() {
@@ -63,6 +65,9 @@ prepare() {
   
   # Fix restoring column status in kmail and ksysguard
   patch -p1 -i ../qheaderview-restore.patch
+  
+  # Fix QHeaderView regression https://bugreports.qt.io/browse/QTBUG-66444
+  patch -p1 -i ../qtbug-66444.patch
 }
 
 build() {
diff --git a/qtbug-66444.patch b/qtbug-66444.patch
new file mode 100644
index 0000000000000000000000000000000000000000..cd57f13523709af77c25c6d5a965642f32b468c5
--- /dev/null
+++ b/qtbug-66444.patch
@@ -0,0 +1,165 @@
+From 9395f35cb18725995910531ca8b09f1d84efa96c Mon Sep 17 00:00:00 2001
+From: Christian Ehrlicher <ch.ehrlicher@gmx.de>
+Date: Sat, 17 Feb 2018 10:02:19 +0100
+Subject: QHeaderView: Preserve settings on layoutChange with empty model
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Do not clear the settings of QHeaderView during layoutChange when the
+model is empty and the section count did not change. This will not work
+when a section is moved or a section is replaced with a new one during
+layoutChange. But since layoutChanged is also called on sorting, this
+patch ensures that the settings are not cleared in this case.
+This restores the behavior to the same as before 5.9.4.
+
+Task-number: QTBUG-66444
+Task-number: QTBUG-65478
+Change-Id: I39989cfd45b42e58f49d18ec014d3a941cadb6c9
+Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
+---
+ src/widgets/itemviews/qheaderview.cpp              | 24 ++++++++
+ .../itemviews/qheaderview/tst_qheaderview.cpp      | 71 ++++++++++++++++++++++
+ 2 files changed, 95 insertions(+)
+
+diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
+index edef2e9bf8..b0359de3ea 100644
+--- a/src/widgets/itemviews/qheaderview.cpp
++++ b/src/widgets/itemviews/qheaderview.cpp
+@@ -2205,6 +2205,30 @@ void QHeaderViewPrivate::_q_sectionsChanged()
+         return;
+     }
+ 
++    bool hasPersistantIndexes = false;
++    for (const auto &item : oldPersistentSections) {
++        if (item.index.isValid()) {
++            hasPersistantIndexes = true;
++            break;
++        }
++    }
++
++    // Though far from perfect we here try to retain earlier/existing behavior
++    // ### See QHeaderViewPrivate::_q_layoutAboutToBeChanged()
++    // When we don't have valid hasPersistantIndexes it can be due to
++    // - all sections are default sections
++    // - the row/column 0 which is used for persistent indexes is gone
++    // - all non-default sections were removed
++    // case one is trivial, in case two we assume nothing else changed (it's the best
++    // guess we can do - everything else can not be handled correctly for now)
++    // case three can not be handled correctly with layoutChanged - removeSections
++    // should be used instead for this
++    if (!hasPersistantIndexes) {
++        if (oldCount != newCount)
++            q->initializeSections();
++        return;
++    }
++
+     // adjust section size
+     if (newCount != oldCount) {
+         const int min = qBound(0, oldCount, newCount - 1);
+diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c69c0de949..97aa8a0299 100644
+--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -206,6 +206,7 @@ private slots:
+     void task248050_hideRow();
+     void QTBUG6058_reset();
+     void QTBUG7833_sectionClicked();
++    void checkLayoutChangeEmptyModel();
+     void QTBUG8650_crashOnInsertSections();
+     void QTBUG12268_hiddenMovedSectionSorting();
+     void QTBUG14242_hideSectionAutoSize();
+@@ -286,6 +287,13 @@ public:
+         endInsertColumns();
+     }
+ 
++    void removeFirstRow()
++    {
++        beginRemoveRows(QModelIndex(), 0, 0);
++        --rows;
++        endRemoveRows();
++    }
++
+     void removeLastRow()
+     {
+         beginRemoveRows(QModelIndex(), rows - 1, rows - 1);
+@@ -328,6 +336,24 @@ public:
+         emit layoutChanged();
+     }
+ 
++    void emitLayoutChanged()
++    {
++        emit layoutAboutToBeChanged();
++        emit layoutChanged();
++    }
++
++    void emitLayoutChangedWithRemoveFirstRow()
++    {
++        emit layoutAboutToBeChanged();
++        QModelIndexList milNew;
++        const auto milOld = persistentIndexList();
++        milNew.reserve(milOld.size());
++        for (int i = 0; i < milOld.size(); ++i)
++            milNew += QModelIndex();
++        changePersistentIndexList(milOld, milNew);
++        emit layoutChanged();
++    }
++
+     int cols, rows;
+     mutable bool wrongIndex;
+ };
+@@ -2332,6 +2358,51 @@ void tst_QHeaderView::QTBUG7833_sectionClicked()
+     QCOMPARE(pressedSpy.at(2).at(0).toInt(), 0);
+ }
+ 
++void tst_QHeaderView::checkLayoutChangeEmptyModel()
++{
++    QtTestModel tm;
++    tm.cols = 11;
++    QTableView tv;
++    tv.setModel(&tm);
++
++    const int section4Size = tv.horizontalHeader()->sectionSize(4) + 1;
++    const int section5Size = section4Size + 1;
++    tv.horizontalHeader()->resizeSection(4, section4Size);
++    tv.horizontalHeader()->resizeSection(5, section5Size);
++    tv.setColumnHidden(5, true);
++    tv.setColumnHidden(6, true);
++    tv.horizontalHeader()->swapSections(8, 10);
++
++    tv.sortByColumn(1, Qt::AscendingOrder);
++    tm.emitLayoutChanged();
++
++    QCOMPARE(tv.isColumnHidden(5), true);
++    QCOMPARE(tv.isColumnHidden(6), true);
++    QCOMPARE(tv.horizontalHeader()->sectionsMoved(), true);
++    QCOMPARE(tv.horizontalHeader()->logicalIndex(8), 10);
++    QCOMPARE(tv.horizontalHeader()->logicalIndex(10), 8);
++    QCOMPARE(tv.horizontalHeader()->sectionSize(4), section4Size);
++    tv.setColumnHidden(5, false);   // unhide, section size must be properly restored
++    QCOMPARE(tv.horizontalHeader()->sectionSize(5), section5Size);
++    tv.setColumnHidden(5, true);
++
++    // adjust
++    tm.rows = 3;
++    tm.emitLayoutChanged();
++
++    // remove the row used for QPersistenModelIndexes
++    tm.emitLayoutChangedWithRemoveFirstRow();
++    QCOMPARE(tv.isColumnHidden(5), true);
++    QCOMPARE(tv.isColumnHidden(6), true);
++    QCOMPARE(tv.horizontalHeader()->sectionsMoved(), true);
++    QCOMPARE(tv.horizontalHeader()->logicalIndex(8), 10);
++    QCOMPARE(tv.horizontalHeader()->logicalIndex(10), 8);
++    QCOMPARE(tv.horizontalHeader()->sectionSize(4), section4Size);
++    tv.setColumnHidden(5, false);   // unhide, section size must be properly restored
++    QCOMPARE(tv.horizontalHeader()->sectionSize(5), section5Size);
++    tv.setColumnHidden(5, true);
++}
++
+ void tst_QHeaderView::QTBUG8650_crashOnInsertSections()
+ {
+     QStringList headerLabels;
+-- 
+cgit v1.1-6-g87c4
+