diff --git a/PKGBUILD b/PKGBUILD
index 2be96a22dcaa76eb2e1276a84e2c00417b5bcc24..8a6b1582ee1ea886302ac44e0f3a46bf94c090cd 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=3
+pkgrel=5
 arch=(x86_64)
 url='http://qt-project.org/'
 license=('GPL3' 'LGPL3' 'FDL' 'custom')
@@ -28,8 +28,13 @@ conflicts=('qtchooser')
 groups=('qt' 'qt5')
 _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")
-sha256sums=('d8660e189caa5da5142d5894d328b61a4d3ee9750b76d61ad74e4eee8765a969')
+		"revert-Set-sharedPainter-correctly-for-QGraphicsEffect.patch"
+		"qtbug-65478.patch"
+		qheaderview-restore.patch::"https://code.qt.io/cgit/qt/qtbase.git/patch/?id=4a04eea4")
+sha256sums=('d8660e189caa5da5142d5894d328b61a4d3ee9750b76d61ad74e4eee8765a969'
+            'e98cb66de308f85ef2d8e05062ada4d1ca4d88ebe836281489d5c0c9c2495a4b'
+            '9afdfc018c3894f12e7a01a8221d9f7be9feba00902d98f0e6a09612b68b2619'
+            '3a1016cbf8c3c4676e6fc406756ffa5a151ffe09153dfc0fa7ed3c16945b0ae5')
 validpgpkeys=('6DD4217456569BA711566AC7F06E8FDE7B45DAAC') # Eric Vidal
 
 prepare() {
@@ -52,6 +57,12 @@ prepare() {
   # Revert upstream commit which breaks some Deepin components (FS#57531)
   # https://bugreports.qt.io/browse/QTBUG-66226
   patch -Np1 -i ../revert-Set-sharedPainter-correctly-for-QGraphicsEffect.patch
+  
+  # Fix kexi crash at startup http://bugreports.qt.io/browse/QTBUG-65478
+  patch -p1 -i ../qtbug-65478.patch
+  
+  # Fix restoring column status in kmail and ksysguard
+  patch -p1 -i ../qheaderview-restore.patch
 }
 
 build() {
diff --git a/qheaderview-restore.patch b/qheaderview-restore.patch
new file mode 100644
index 0000000000000000000000000000000000000000..27bb4f46e00fbb8f80b5d40b94231f490f832a3d
--- /dev/null
+++ b/qheaderview-restore.patch
@@ -0,0 +1,115 @@
+From 4a04eea4f4316684e20c509352c6c533cf39306e Mon Sep 17 00:00:00 2001
+From: David Faure <david.faure@kdab.com>
+Date: Thu, 1 Mar 2018 11:04:00 +0100
+Subject: QHeaderView: fix inconsistent saved state, ignored during restore
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The code that updates a section size must also update length,
+otherwise saveState can end up saving inconsistent state, and
+restoreState() goes to an early-return, not doing anything.
+
+The actual bug was fixed meanwhile because _q_sectionsChanged is called
+again, which recalculates length. I still see this only as a safety
+measure, every other code path that changes section sizes updates length
+right away.
+
+Change-Id: I6cc16261692d93b3640afafef600a5bdff8dca0c
+Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
+---
+ src/widgets/itemviews/qheaderview.cpp              |  6 ++-
+ .../widgets/itemviews/qtreeview/tst_qtreeview.cpp  | 53 ++++++++++++++++++++++
+ 2 files changed, 58 insertions(+), 1 deletion(-)
+
+diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
+index 5cbf642802..b7048d1616 100644
+--- a/src/widgets/itemviews/qheaderview.cpp
++++ b/src/widgets/itemviews/qheaderview.cpp
+@@ -2191,7 +2191,11 @@ void QHeaderViewPrivate::_q_sectionsAboutToBeChanged(const QList<QPersistentMode
+     if (stretchLastSection && lastSectionLogicalIdx >= 0 && lastSectionLogicalIdx < sectionItems.count()) {
+         const int visual = visualIndex(lastSectionLogicalIdx);
+         if (visual >= 0 && visual < sectionItems.size()) {
+-            sectionItems[visual].size = lastSectionSize;
++            auto &itemRef = sectionItems[visual];
++            if (itemRef.size != lastSectionSize) {
++                length += lastSectionSize - itemRef.size;
++                itemRef.size = lastSectionSize;
++            }
+         }
+     }
+     for (int i = 0; i < sectionItems.size(); ++i) {
+diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+index 5293ba487a..347d2a81e6 100644
+--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
++++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+@@ -162,6 +162,7 @@ private slots:
+     void renderToPixmap();
+     void styleOptionViewItem();
+     void keyboardNavigationWithDisabled();
++    void saveRestoreState();
+ 
+     void statusTip_data();
+     void statusTip();
+@@ -4076,6 +4077,58 @@ void tst_QTreeView::keyboardNavigationWithDisabled()
+     QCOMPARE(view.currentIndex(), model.index(6, 0));
+ }
+ 
++class RemoveColumnOne : public QSortFilterProxyModel
++{
++public:
++    bool filterAcceptsColumn(int source_column, const QModelIndex &) const override
++    {
++        if (m_removeColumn)
++            return source_column != 1;
++        return true;
++    }
++    void removeColumn()
++    {
++        m_removeColumn = true;
++        invalidate();
++    }
++private:
++    bool m_removeColumn = false;
++};
++
++
++void tst_QTreeView::saveRestoreState()
++{
++    QStandardItemModel model;
++    for (int i = 0; i < 100; i++) {
++        QList<QStandardItem *> items;
++        items << new QStandardItem(QLatin1String("item ") + QString::number(i)) << new QStandardItem(QStringLiteral("hidden by proxy")) << new QStandardItem(QStringLiteral("hidden by user"));
++        model.appendRow(items);
++    }
++    QCOMPARE(model.columnCount(), 3);
++
++    RemoveColumnOne proxy;
++    proxy.setSourceModel(&model);
++    QCOMPARE(proxy.columnCount(), 3);
++
++    QTreeView view;
++    view.setModel(&proxy);
++    view.resize(500, 500);
++    view.show();
++    view.header()->hideSection(2);
++    QVERIFY(view.header()->isSectionHidden(2));
++    proxy.removeColumn();
++    QCOMPARE(proxy.columnCount(), 2);
++    QVERIFY(view.header()->isSectionHidden(1));
++    const QByteArray data = view.header()->saveState();
++
++    QTreeView view2;
++    view2.setModel(&proxy);
++    view2.resize(500, 500);
++    view2.show();
++    view2.header()->restoreState(data);
++    QVERIFY(view2.header()->isSectionHidden(1));
++}
++
+ class Model_11466 : public QAbstractItemModel
+ {
+     Q_OBJECT
+-- 
+cgit v1.1-6-g87c4
+
diff --git a/qtbug-65478.patch b/qtbug-65478.patch
new file mode 100644
index 0000000000000000000000000000000000000000..c52bda12c4ebd2dabbd9b3b770e8ac5c2e5855fe
--- /dev/null
+++ b/qtbug-65478.patch
@@ -0,0 +1,30 @@
+From e8425f9e52c9df0ce0fbf122adff3ef6930f9961 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= <tmartsum@gmail.com>
+Date: Wed, 28 Feb 2018 09:23:54 +0100
+Subject: QHeaderView: Fix crash in layout about to change
+
+Before there was a risk looking up e.g index -1 if there
+were no visible sections in layoutAboutToChange.
+
+Change-Id: Ic911e4292e8e8c4892fef1c0f34cf7dccaad2bac
+Task-number: QTBUG-65478
+Reviewed-by: David Faure <david.faure@kdab.com>
+---
+diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
+index 26d7c5472a..708b9b44ca 100644
+--- a/src/widgets/itemviews/qheaderview.cpp
++++ b/src/widgets/itemviews/qheaderview.cpp
+@@ -2163,9 +2163,11 @@ void QHeaderViewPrivate::_q_sectionsAboutToBeChanged()
+     layoutChangePersistentSections.clear();
+     layoutChangePersistentSections.reserve(std::min(10, sectionItems.count()));
+     // after layoutChanged another section can be last stretched section
+-    if (stretchLastSection) {
++    if (stretchLastSection && lastSectionLogicalIdx >= 0 && lastSectionLogicalIdx < sectionItems.count()) {
+         const int visual = visualIndex(lastSectionLogicalIdx);
+-        sectionItems[visual].size = lastSectionSize;
++        if (visual >= 0 && visual < sectionItems.size()) {
++            sectionItems[visual].size = lastSectionSize;
++        }
+     }
+     for (int i = 0; i < sectionItems.size(); ++i) {
+         auto s = sectionItems.at(i);
diff --git a/rebuild.list b/rebuild.list
index 70f37d583ebb47efcbe9650bc01fb64e7a42b958..fdb9fec632b54a771ab57458b92a3a9740aefb8d 100644
--- a/rebuild.list
+++ b/rebuild.list
@@ -11,6 +11,7 @@ qt5ct
 akonadi
 deepin-dock
 deepin-file-manager
+deepin-qt-dbus-factory
 deepin-qt5integration
 deepin-qt5dxcb-plugin
 dtkwidget