summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-03-11 21:27:51 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-03-14 16:50:59 +0000
commitb8d5e0b4ce2f1daef35dad38f5048040ae915412 (patch)
tree6218c7a64afcd77f189707e6d7c8296bf616d123 /src/widgets
parent02c25f334da817fe206aa28ba0e045c57d8c0359 (diff)
QAbstractItemView: Don't let editor width exceed item width if not needed
The editor geometry was adjusted in RTL but not in LTR mode before Qt5.11. 3ed91da4997cf793742e5bba2adb3dbec9ecd458 fixed this but now all editors are shown with their default size instead adjusting to the item width. This works in most cases but fails for small column widths and e.g. a QDoubleSpinBox. Therefore adjust the size policy for the editors so their default size is ignored and therefore the column width is used. Don't do this for a QDateTimeEdit since this makes no sense to only show a cut of part of the editor. Fixes: QTBUG-74327 Change-Id: Ie526155571bf24a2d8f38e988d8b2af4bfcc92ba Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/itemviews/qitemeditorfactory.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp
index 0986da9707..1465ee71a7 100644
--- a/src/widgets/itemviews/qitemeditorfactory.cpp
+++ b/src/widgets/itemviews/qitemeditorfactory.cpp
@@ -244,6 +244,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
case QVariant::Bool: {
QBooleanComboBox *cb = new QBooleanComboBox(parent);
cb->setFrame(false);
+ cb->setSizePolicy(QSizePolicy::Ignored, cb->sizePolicy().verticalPolicy());
return cb; }
#endif
#if QT_CONFIG(spinbox)
@@ -252,12 +253,14 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
sb->setFrame(false);
sb->setMinimum(0);
sb->setMaximum(INT_MAX);
+ sb->setSizePolicy(QSizePolicy::Ignored, sb->sizePolicy().verticalPolicy());
return sb; }
case QVariant::Int: {
QSpinBox *sb = new QSpinBox(parent);
sb->setFrame(false);
sb->setMinimum(INT_MIN);
sb->setMaximum(INT_MAX);
+ sb->setSizePolicy(QSizePolicy::Ignored, sb->sizePolicy().verticalPolicy());
return sb; }
#endif
#if QT_CONFIG(datetimeedit)
@@ -284,6 +287,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
sb->setFrame(false);
sb->setMinimum(-DBL_MAX);
sb->setMaximum(DBL_MAX);
+ sb->setSizePolicy(QSizePolicy::Ignored, sb->sizePolicy().verticalPolicy());
return sb; }
#endif
#if QT_CONFIG(lineedit)