|
@@ -3,6 +3,7 @@
|
|
|
#include "../common/JMessageTip.h"
|
|
|
#include "../common/JQCommon.h"
|
|
|
#include <QHash>
|
|
|
+#include <utility>
|
|
|
|
|
|
LightJoystickSwitchPage::LightJoystickSwitchPage(QWidget *parent)
|
|
|
: QWidget(parent)
|
|
@@ -219,6 +220,25 @@ void LightJoystickSwitchPage::DisableLayoutWidgets(QLayout* layout, bool isShow
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void LightJoystickSwitchPage::AdjustComboBoxWidth(QComboBox* comboBox)
|
|
|
+{
|
|
|
+ if (!comboBox || comboBox->count() == 0) return;
|
|
|
+
|
|
|
+ // 获取字体度量
|
|
|
+ QFontMetrics metrics(comboBox->font());
|
|
|
+ int max_width = 0;
|
|
|
+
|
|
|
+ // 遍历所有项目
|
|
|
+ for (int i = 0; i < comboBox->count(); ++i)
|
|
|
+ {
|
|
|
+ const QString text = comboBox->itemText(i);
|
|
|
+ max_width = qMax(max_width, metrics.horizontalAdvance(text));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ comboBox->setMinimumWidth(max_width);
|
|
|
+}
|
|
|
+
|
|
|
template<class T>
|
|
|
void LightJoystickSwitchPage::DeduplicationBox(QComboBox* pCom, const T& veTemp, int nIndex)
|
|
|
{
|
|
@@ -255,6 +275,9 @@ void LightJoystickSwitchPage::DeduplicationBox(QComboBox* pCom, const T& veTemp,
|
|
|
pCom->addItem(strName);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ AdjustComboBoxWidth(pCom);
|
|
|
+ pCom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
}
|
|
|
|
|
|
void LightJoystickSwitchPage::BondSliderAndLineEdit(QSlider* slider, QLineEdit* lineEdit)
|