修改pressPos未赋值问题

This commit is contained in:
lixueman 2022-11-21 17:14:05 +08:00
parent 42a09e95fd
commit 90157f6306
4 changed files with 4 additions and 5 deletions

View File

@ -92,8 +92,9 @@ void KListView::mouseMoveEvent(QMouseEvent *e)
void KListView::mousePressEvent(QMouseEvent *event)
{
if ((this->indexAt(event->pos()).isValid()) && event->button() == Qt::LeftButton) {
m_pressApp = m_listmodel->data(this->indexAt(event->pos()), Qt::DisplayRole);
m_pressPos = event->pos();
if ((this->indexAt(m_pressPos).isValid()) && event->button() == Qt::LeftButton) {
m_pressApp = m_listmodel->data(this->indexAt(m_pressPos), Qt::DisplayRole);
}
return QListView::mousePressEvent(event);
}

View File

@ -36,6 +36,7 @@ public:
int module = 0;
double m_transparency;
QVariant m_pressApp;
QPoint m_pressPos;
UkuiMenuInterface *m_ukuiMenuInterface = nullptr;
protected:
void paintEvent(QPaintEvent *e);

View File

@ -50,7 +50,6 @@ ListView::~ListView()
void ListView::initWidget()
{
setAttribute(Qt::WA_TranslucentBackground);
this->setAcceptDrops(true);
viewport()->setAttribute(Qt::WA_TranslucentBackground);
viewport()->setAutoFillBackground(false);
this->setSelectionMode(QAbstractItemView::SingleSelection);

View File

@ -57,8 +57,6 @@ private:
int h = 0;
int m_preRowCount;
bool m_scrollbarState = true;
QPoint m_pressPos;
private Q_SLOTS:
void onClicked(QModelIndex index);//点击item