diff --git a/src/UserInterface/ListView/listview.cpp b/src/UserInterface/ListView/listview.cpp index f781921..89be87b 100755 --- a/src/UserInterface/ListView/listview.cpp +++ b/src/UserInterface/ListView/listview.cpp @@ -29,6 +29,7 @@ ListView::ListView(QWidget *parent/*, int width, int height, int module*/): this->h = 540; this->module = 1; initWidget(); + setAttribute(Qt::WA_AcceptTouchEvents); m_listmodel = new QStandardItemModel(this); this->setModel(m_listmodel); m_ukuiMenuInterface = new UkuiMenuInterface; @@ -95,6 +96,21 @@ void ListView::updateData(QVector data) } } +bool ListView::event(QEvent *e) +{ + switch (e->type()) { + case QEvent::TouchBegin: + m_scrollbarState = false; + break; + case QEvent::ChildRemoved: + m_scrollbarState = true; + break; + default: + break; + } + return QListView::event(e); +} + void ListView::onClicked(QModelIndex index) { QVariant var = m_listmodel->data(index, Qt::DisplayRole); @@ -119,14 +135,18 @@ void ListView::onClicked(QModelIndex index) void ListView::enterEvent(QEvent *e) { Q_UNUSED(e); - this->selectionModel()->clear(); - this->verticalScrollBar()->setVisible(true); + if (m_scrollbarState) { + this->selectionModel()->clear(); + verticalScrollBar()->setVisible(true); + } } void ListView::leaveEvent(QEvent *e) { Q_UNUSED(e); - this->verticalScrollBar()->setVisible(false); + if (m_scrollbarState) { + verticalScrollBar()->setVisible(false); + } } void ListView::paintEvent(QPaintEvent *e) diff --git a/src/UserInterface/ListView/listview.h b/src/UserInterface/ListView/listview.h index ff39d9b..f9125e8 100755 --- a/src/UserInterface/ListView/listview.h +++ b/src/UserInterface/ListView/listview.h @@ -49,11 +49,12 @@ protected: void leaveEvent(QEvent *e) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *e) override; void keyPressEvent(QKeyEvent *e); - + bool event(QEvent *e); private: int w = 0; int h = 0; int m_preRowCount; + bool m_scrollbarState = true; private Q_SLOTS: