mirror of
https://github.com/ukui/ukui-control-center.git
synced 2026-10-24 05:44:55 -07:00
Description: 修复快速移动导致二级导航菜单显示不全,hover和选中长度不一致的问题,优化bug#51061的解决方案 Log: 在LeftMenuList的resizeEvent里面修改item的长度,固定图标长度,在LeftWidgetItem的resizeEvent里面修改textLabel的长度
31 lines
730 B
C++
31 lines
730 B
C++
#include "leftmenulist.h"
|
|
|
|
#include <QDebug>
|
|
|
|
LeftMenuList::LeftMenuList(QWidget *parent) : QListWidget(parent) {
|
|
|
|
}
|
|
|
|
void LeftMenuList::resizeEvent(QResizeEvent *event) {
|
|
int maxItemWidth = 0;
|
|
for (int i = 0; i < this->count(); i++) {
|
|
QWidget *item = this->itemWidget(this->item(i));
|
|
if (item->width() > maxItemWidth) {
|
|
maxItemWidth = item->width();
|
|
}
|
|
item->setFixedWidth(this->width() - 24);
|
|
};
|
|
if (maxItemWidth < 100) {
|
|
this->setMinimumWidth(maxItemWidth);
|
|
}
|
|
|
|
QListWidget::resizeEvent(event);
|
|
}
|
|
|
|
void LeftMenuList::mousePressEvent(QMouseEvent *event)
|
|
{
|
|
if (event->button() == Qt::LeftButton) {
|
|
QListWidget::mousePressEvent(event);
|
|
}
|
|
}
|