From 82a87e96b3f273e91611764a69782260327936dc Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 6 Oct 2018 12:59:59 -0700 Subject: [PATCH] Include the indicator in combo box width --- app/gui/AutoResizingComboBox.qml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/gui/AutoResizingComboBox.qml b/app/gui/AutoResizingComboBox.qml index 789abd53..7bf7973e 100644 --- a/app/gui/AutoResizingComboBox.qml +++ b/app/gui/AutoResizingComboBox.qml @@ -3,9 +3,9 @@ import QtQuick.Controls 2.2 // https://stackoverflow.com/questions/45029968/how-do-i-set-the-combobox-width-to-fit-the-largest-item ComboBox { - property int comboBoxWidth + property int textWidth - width: comboBoxWidth + 2*leftPadding + 2*rightPadding + implicitWidth: leftPadding + textWidth + indicator.width + rightPadding TextMetrics { id: popupMetrics @@ -20,12 +20,12 @@ ComboBox { // We call this every time the options change (and init) // so we can adjust the combo box width here too onActivated: { - comboBoxWidth = 0 + textWidth = 0 for (var i = 0; i < count; i++){ textMetrics.text = textAt(i) popupMetrics.text = textAt(i) - comboBoxWidth = Math.max(textMetrics.width, comboBoxWidth) - comboBoxWidth = Math.max(popupMetrics.width, comboBoxWidth) + textWidth = Math.max(textMetrics.width, textWidth) + textWidth = Math.max(popupMetrics.width, textWidth) } } }