summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qcombobox.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QComboBox: Revert recreation of ComboBox Container on style changeWladimir Leuschner2024-04-111-17/+1
| | | | | | | | | | | | In commit 9da8d67b3bca1d40ae221a9c6be218fe57759724 a recreation of the ComboBox Container was introduced, since QWindows11Style depends on WA_TranslucentBackground flag, whereas the other styles don't set this flag. This leads to the destruction of user supplied views we don't own. Fixes: QTBUG-124191 Pick-to: 6.7 Change-Id: I4a693f612ddc299696b9de0d87c94d88c04d9b39 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Delete QComboBoxPrivateContainer while the combo box is still aliveTor Arne Vestbø2024-03-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Destroying the QComboxBox will, once it reaches the QWidget destructor, close all popups, including the QComboBoxPrivateContainer, which emits signals on behalf of the QComboBox, that is now gone. Regression after d8e110054876b1cbf186e95bac5561a237ee1c13. The old-syle signal-slot syntax had the advantage of not delivering signals to slots in derived classes after that derived class's destructor had finished running (because we called via the virtual qt_metacall). The new syntax made no checks, so a conversion from the old to the new syntax may introduce crashes or other data corruptions at runtime if the destructor had completed. See 0e72a846d379ba02ff80ecac2526640a05b872b6. We also need a QPointer for the QComboBoxPrivateContainer, as the container may be deleted from outside QComboBox, as seen in the tst_QGraphicsProxyWidget::bypassGraphicsProxyWidget() test, where the QGraphicsProxyWidget proxies the QComboBoxPrivateContainer. Pick-to: 6.7 6.6 6.5 Change-Id: I7590cc2821c73a6762f281504aa62f0c2b472252 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QComboBox: ignore hidden items when calculating popup sizeChristian Ehrlicher2024-01-121-0/+3
| | | | | | | | | | | The popup size depends on the max visible items property. But the loop did not ignore the hidden items which results in fewer items in the popup than allowed. Fixes: QTBUG-120574 Pick-to: 6.7 6.6 6.5 Change-Id: Ic3c503a5272d6839aee158740e096405ca8887d6 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QComboBox: Fix hover over list viewAxel Spoerl2023-12-211-3/+1
| | | | | | | | | | | | | 9da8d67b3bca1d40ae221a9c6be218fe57759724 has commented out setting the current index of the combo box container during a mouse hover event. That has caused a regression. Amend the patch and enable visual hover effect. Fixes: QTBUG-120167 Pick-to: 6.7 Change-Id: Ic12e70f9f70ac2f7b9604580562c35551659c5e2 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* a11y: QComboBox: Reset all model connections when setting modelMichael Weghorn2023-12-181-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When setting the model either directly for the combobox itself or for the combobox's view, disconnect from the model signals and connect to them anew. Always set the model for the view first before connecting the combobox's own slots to the model's signals. Since slots are activated in the order in which they are connected [1] and both of them are connected to the QAbstractItemModel::rowsInserted signal, this ensures that the QAbstractItemViewPrivate::rowsInserted/QListView::rowsInserted slot will get activated before the QComboBoxPrivate::rowsInserted one. (QAbstractItemView::setModel connects its slots to the model's signals.) Activating these slots the other way around is problematic as described in more detail in ecef7046245f3adee9366d3543e4ed2a09f65735 and QTBUG-120121. (macOS accessibility bridge depends on QAbstractItemViewPrivate::rowsInserted to update its table representation, which may be necessary before activating other slots; ATs or platform a11y caches may depend on correct event order.) In a quick test, this commit fixes the QTBUG-119526 crash reliably reproducible after 5093e517b924074ab6e63658c87237be315a17e6 even without the previous fix ecef7046245f3adee9366d3543e4ed2a09f65735 in place. However, leave that one in place, too, as relying on the order in which the connected slots are called is quite fragile (s. the discussion in the Gerrit change for ecef7046245f3adee9366d3543e4ed2a09f65735). [1] https://doc.qt.io/qt-6/qobject.html#connect Fixes: QTBUG-120121 Task-number: QTBUG-119526 Pick-to: 6.7 6.6 6.5 Change-Id: If75fef661f7fcfc1e30e90ec851a2555cf25a65d Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* QComboBox: inform accessibility about model change before selectingVolker Hilsheimer2023-12-091-0/+11
| | | | | | | | | | | | | | | | | | | | | QComboBox implicitly selects the first item that gets inserted into the model. This happens in response to the model's rowInserted signal, at which point the item view might not have handled the rowInserted signal yet. Because of that, the view couldn't update the accessibility bridge, so informing accessibility about a row being selected that doens't exist in the bridge's representation of the table yet will result in data being out of sync, and depending on the bridge implementation trigger asserts. Fix this by explicitly updating the accessibility bridge before implicitly selecting the first row. Fixes: QTBUG-119526 Fixes: QTBUG-118585 Pick-to: 6.6 6.5 Change-Id: I2830c00751b3f18feb5d9252b23823c80229fed1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QComboBox: don't eat non-printable key strokesChristian Ehrlicher2023-11-231-2/+3
| | | | | | | | | | | | | QComboBox in non-editable mode passes all keyboard input to the internal item search. This was done regardless if the character is printable or not and therefore e.g. '\t' composed by Key_Tab + ControlModifier was accepted and not passed to the parent (in the bug report to the QTabWidget which could not switch tabs due to that). Pick-to: 6.6 6.5 Fixes: QTBUG-118605 Change-Id: If39423587460a70231c735df4912b72c5ae77475 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Improve the QCombobox DocumentationSafiyyah Moosa2023-10-311-45/+56
| | | | | | | | | | | | | | | The purpose of this commit is to improve the QCombobox documentation. The following updates were made: - The Combobox image was udated with a better quality image. - The brief was updated to make it more understandable. - The detailed description was updated with subsection titles. - Full stops were added to the sentences that were missing them. Fixes: QTBUG-117748 Pick-to: 6.5 6.6 Change-Id: I417a720299ac0eb2be3f080f2fc0f76a27242423 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Introduce Windows 11 styled ComboBox in QWindows11StyleWladimir Leuschner2023-10-271-2/+21
| | | | | | | | QComboBox is adapted to use the WinUI3 style. Task-number: QTBUG-113513 Change-Id: I300157a7ce9162be73ccd4acfc50b12f7166dc2d Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Include what you need: <QPointer>Marc Mutz2023-10-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | All these TUs relied on transitive includes of qpointer.h, maybe to a large extent via qevent.h, though, given that qevent.h is more or less the only public QtBase header that includes qpointer.h, something else seems to be at play here. Said qevent.h actually needs QPointer in-name-only, so a forward declaration would suffice. Prepare for qevent.h dropping the include. The algorithm I used was: If the TU mentions 'passiveGrabbers', the name of the QEvent function that returns QPointers, and the TU doesn't have qpointer.h included explicitly, include it. That may produce False Positives, but better safe than sorry. Otherwise, in src/, add an include to all source and header files which mention QPointer. Exception: if foo.h of a foo.cpp already includes it, don't include again. Task-number: QTBUG-117670 Change-Id: I3321cccdb41ce0ba6d8a709cea92427aba398254 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Preparations to deprecate QItemDelegateChristian Ehrlicher2023-10-051-1/+1
| | | | | | | | | | | | | QItemDelegate was superseded since Qt4 by QStyledItemDelegate but it took until Qt6.7 to remove the last occurrences in qtbase. - remove unused includes / replace with qabstractitemdelegate.h - replace references in the documentation with QStyledItemDelegate - adjust the examples and tests to use QStyledItemDelegate Pick-to: 6.5 6.6 Change-Id: I246755004ce2d01192a726ca0972106c237df0cc Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* a11y: Keep current combobox entry in syncMichael Weghorn2023-09-291-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When changing the selected index in a combo box, also update the current index in the item view's selection model right away, and don't delay this until when the combobox popup gets shown in QComboBox::showPopup. This is needed to make sure that the selection is properly exposed to the accessibility layer. On the accessibility layer, QAccessibleComboBox, the a11y implementation for the combobox, exposes the entries in its list child (s. QAccessibleComboBox::child) and Orca queries the selected item when the combobox gets focus, which didn't return the proper results earlier, resulting in no or the wrong entry getting announced. Extend the existing combobox a11y tests accordingly. Pick-to: 6.6 6.5 Fixes: QTBUG-117644 Change-Id: Ia26de5eafd229f7686745a2fbe03fc1eb6a713f8 Reviewed-by: Liang Qi <liang.qi@qt.io>
* QComboBoxPrivateContainer: add missing keyEvent->accept()Axel Spoerl2023-09-291-0/+3
| | | | | | | | | | | Call QEvent::accept() when a key event has been acted on. This prevents redundant event delivery and consumption. Task-number: QTBUG-117644 Pick-to: 6.6 6.5 Change-Id: I069c61c14890577683894f165fd2585ba05c45ff Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Reviewed-by: Liang Qi <liang.qi@qt.io>
* QComboBox: Modernise connect statementsAxel Spoerl2023-09-291-89/+105
| | | | | | | | | | | | | | Replace string based syntax with PMF. Use QObjectPrivate::connect. Rename _q_ functions. Fix dangling connections in QComboBox d'tor: Completely disconnect model, instead of only disconnecting QObject::destroyed. Task-number: QTBUG-117644 Pick-to: 6.6 6.5 Change-Id: Ie87ac4881029ed1ef2f5c627f631cc54ccb39706 Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Reviewed-by: Liang Qi <liang.qi@qt.io>
* QComboBox on macOS: guard against destruction while native popup is openVolker Hilsheimer2023-09-081-6/+13
| | | | | | | | | | | | | | | | | | | | Since showing the native popup on macOS is blocking and processes events the QComboBox might get destroyed while the popup is open. Guard against this by using QPointer and returning early (dismissing the scope guard that would otherwise reset the menu's parent, writing to freed memory). The problem is then that the native popup remains visible, as the destructor of QComboBox calls cleanupNativeCombobox which destroys the platform menu (i.e. the QCocoaMenu instance), but that doesn't dismiss() the popup. Add a call to dismiss() to the QCocoaMenu destructor to make sure that destroying the menu closes it first. Fixes: QTBUG-116155 Pick-to: 6.6 6.5 Change-Id: If0ac19796603667f4c8e80c302710dc4c9aded50 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QtWidgets: code tidies: use the 4-arg connect overloadGiuseppe D'Angelo2023-07-051-1/+1
| | | | | | | | The 3-arg connect is error-prone and makes the lifetime of the connection unclear. Change-Id: I1b6b10d814412f02ae534d408723762ba7cd815b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QComboBox: scroll the popup to the top before positioning itRichard Moe Gustavsen2023-06-151-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the style changes while a popup is open (or about to close), the popup will change style as well before it's hidden. And this can result in the popup window briefly ending up smaller than what it needs to be, in order to fit all the menu items. In that case, it will show 'up' and 'down' widgets in the menu that auto scrolls it when hovered. And all this can happen for a split second while the menu is about to close (as a result of the user clicking on a menu item). A bug happens because of this if you click on the last menu item in the list, and this causes the style to change. In that case, the 'down' widget will end up directly underneath the mouse for a split second, which will trigger an auto-scroll timer to start. This timer will trigger a bit later, after the popup has been hidden, and scroll the list view a bit down. The result is that the next time you open the popup, it ends up at the wrong place on the screen in a failed attempt to center the current index on top of the combobox. This patch will make sure that we always scroll the list view to the top before we start calculating where the popup should be placed on the screen. Otherwise the geometry ends up wrong since the popup will anyway be resized (if possible) to fit all the menu items before it's shown and should therefore not take scrolling into account. Pick-to: 6.6 6.5 Fixes: QTBUG-113765 Change-Id: I61b5b832904de471c2303fc67325feec322b1449 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Fix no-op emission of QComboBox::currentTextChangedAxel Spoerl2023-06-131-4/+16
| | | | | | | | | | | | | | | | | | currentTextChanged is emitted when the current index changes and the current text doesn't. This can be the case, if - old and new index have identical text values - an item is removed below the current index [ChangeLog][Widgets][QComboBox] emit currentTextChanged only, if currentText changes. Add a corresponding test in tst_QComboBox::currentText(). Fixes: QTBUG-113717 Pick-to: 6.6 Change-Id: I847874f0792b29a2841e50bb82d06ad496fb02c3 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix hiding in QComboBox when there is no selectionVolker Hilsheimer2023-05-041-19/+18
| | | | | | | | | | | If there is an effect on the selected item we want to show it, but if there is no item to highligh we just close the combo. Fixes: QTBUG-113311 Pick-to: 6.5 Change-Id: I287af75d27e6f6ff969e4706e16cc8c4812129ea Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QComboBox: don't call index(-1, 0) on the underlying modelDavid Faure2023-04-191-1/+1
| | | | | | | | | This is invalid and might assert in the model (e.g. in QConcatenateTablesProxyModel) Pick-to: 6.5 6.2 Change-Id: I6602d8b9eca83ef6cae760944a999d55244bb181 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QComboBox: don't call data(invalid index) on the underlying modelDavid Faure2023-04-181-0/+2
| | | | | | | | | | | QComboBoxPrivate::itemIcon() wasn't checking for an invalid index, unlike QComboBoxPrivate::itemText(). QComboBoxPrivate::setCurrentIndex calls updateLineEditGeometry, which calls QComboBox::itemIcon, even for an invalid combobox. Pick-to: 6.5 6.2 Change-Id: I5e6105ae56836cd237a91a405d331f1424f49b37 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QComboBox: Disable items marked as disabled in native popupsSebastian Beckmann2023-03-311-0/+2
| | | | | | | Fixes: QTBUG-56064 Pick-to: 6.5 6.2 5.15 Change-Id: I00a17a19b4c14c874e16ec863e794218f0570346 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QComboBox: reset indexBeforeChange to -1 if index is invalidatedAxel Spoerl2023-03-281-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The member variable indexBeforeChange is member-initialized with -1 and changed to the current row, if a valid index is set. It is used to check, if the model has been reset to an empty model and/or the index has been invalidated. The result is used to decide, if the currentIndexChanged signal is emitted or not. If a combo box had a valid index and it is invalidated afterwards (e.g. because the combobox has no more entries), indexBeforeChange is not reset to -1. The redundant signal emission is therefore prevented only the first time. This patch resets indexBeforeChange if the index is invalidated or the last item is removed from the combo box. It also adds a no-op check to tst_QComboBox::currentIndex. The test data sets "check that setting the index to -1 works" and "check that current index is invalid when removing the only item" check the respective use cases. As a drive-by, variable names and QObect::connect syntax have been cleaned up in tst_QComboBox::currentIndex. Fixes: QTBUG-108614 Pick-to: 6.5 6.2 Change-Id: Ib6dfa887d9247f2c47df065039d69ba57c32fa24 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix build with -no-feature-shortcutTasuku Suzuki2023-01-171-0/+2
| | | | | | | | qplatformtheme.h complains about Q_GADGET without <QtCore/QKeySequence> Pick-to: 6.5 Change-Id: I7561bd3e2484c44842cd25ab12aacb9c00ebedfd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QComboBox: Don't dereference potential nullptr, simplifyVolker Hilsheimer2022-12-081-5/+2
| | | | | | | | | | | | | | | | | | | | | | Amends a874087504cf5af8bb4171d4137f23f100b7063b, which tested whether d->container is nullptr to decide whether to hide the popup, and then dereferences d->container later without checking again. This raised a correct static analyzer warning. Simplify that logic. hidePopup() does nothing if there is no visible container, and we don't want to accept() the cancel key if there isn't. So the closeOnCancel logic isn't actually needed, we only need to accept the ShortcutOverride to make sure that QComboBox sees the Cancel key even if there is a shortcut registered, and then we can handle and accept the cancel key to call hidePopup() only if the popup is visible. Add test to verify that this interaction works as expected. Pick-to: 6.4 Task-number: QTBUG-108908 Change-Id: I60d92b068f0f5139d629cf4a58e225512170df77 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QComboBox: hide the popup on keypress rather than ShortcutOverrideVolker Hilsheimer2022-12-051-1/+9
| | | | | | | | | | | | | | | | | | | Qt sends a ShortcutOverride to the focus widget to evaluate whether the widget's key event handling has higher priority than shortcut handling. A KeyPress is then sent if the ShortcutOverride comes back accepted, or if the Shortcut event returns ignored. QComboBox needs to accept the ShortcutOverride for Cancel, so that hiding the popup has priority over application shortcuts. But it should only hide the popup when the KeyPress event actually arrives, as otherwise the the focus widget changes (from popup to combobox), which breaks event delivery on macOS. Fixes: QTBUG-108908 Pick-to: 6.4 6.4.2 Change-Id: Ie9cce1c2041cbe0e41be301686d7c3b5683e9f10 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QComboBox: remove dead keyboard-navigation codeVolker Hilsheimer2022-10-311-32/+1
| | | | | | | The code called setEditFocus, which no longer exists anywhere in Qt. Change-Id: Icd02b8d8b204819188e090e7462309e5c5a5b3d6 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QComboBox: refactor item flashing code in hidePopupVolker Hilsheimer2022-10-291-24/+37
| | | | | | | | | | | | | | Instead of using a local event loop, control the flashing through timers and lambdas. Move the actual hiding of the popup then into a helper that gets called when the flashing is done. Note: this changes behavior -the popup will not be hidden when hidePopup returns. And since events continue get processed during the flashing effect, we might still get reentrancy (so the code added in accc833e556ba54038d1cc7e261a936492145240 has to stay anyway). Change-Id: I2ce20520dea16bd3be78544e9fdd059a2969a795 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix QComboBox supressing a QDialogs default buttonRobert Griebl2022-10-171-0/+2
| | | | | | | | | | | | | Commit 64ffe0a broke pressing RETURN aka. the default key in a dialog to close it, when a read-only QComboBox has the focus. Before that patch, Enter + Return were actively ignore()d, but this code path was removed, resulting in those keys to be auto-accepted. Fixes: QTBUG-107262 Pick-to: 6.4 Change-Id: I3dd8dca7d2f9d94f5172adc92ef508fe81c0df57 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QComboBox: remove dead codeVolker Hilsheimer2022-10-121-20/+1
| | | | | | | | | We used to explicitly fade out combobox popups on macOS, but even the cocoa platform plugin no longer implements a fadeWindow function. Pick-to: 6.4 Change-Id: I5cd61da2c755ec0f312c451f0ea966aa48399385 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QComboBox: Prevent recursion in hidePopupVolker Hilsheimer2022-08-271-1/+9
| | | | | | | | | | | | | | | | | | | With styles that want the selected combobox item to flash, QComboBox runs a modal event loop in hidePopup. This might result in reentrancy if a mouseReleaseEvent is processed during the 60 ms of flashing. Since mouseReleaseEvent calls hidePopup again, we end up reentrancy and possibly undefined behavior which has caused crashes with Qt Creator on macOS. Prevent the reentrancy of hidePopup using a boolean flag. Since QBoolBlocker (or QScopedValueRollback) cannot be used with a bit flag, use a QScopeGuard to reset the flag reliably. Fixes: QTBUG-105951 Change-Id: Iaa5df47b93217fc8dff621764ac4005bbc3459b7 Reviewed-by: Eike Ziller <eike.ziller@qt.io> (cherry picked from commit 2af64c4577e42fecfeab9611c15fa8526bb09988) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QComboBox: emit currentIndexChanged() and currentTextChanged() when the ↵Ivan Solovev2022-06-161-1/+5
| | | | | | | | | | | | | | | | | | model is cleared QComboBox uses QPersistentModelIndex to store the current index of the underlying model. When the model is cleared, that index is automatically invalidated, so calling QComboBoxPrivate::setCurrentIndex(QModelIndex()) does not result in signals being emitted, because we do not detect the index change. This patch uses indexBeforeChange to detect such situation and emit all necessary signals. Fixes: QTBUG-103007 Pick-to: 6.4 6.3 6.2 Change-Id: I29326830a30a17900839e8d1737a08bd940081ea Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Replace QT_NO_ACCESSIBILITY with QT_CONFIG(accessibility)Allan Sandfeld Jensen2022-06-151-6/+6
| | | | | | | Pick-to: 6.4 Change-Id: Iee4bd8970810be1b23bdba65a74de912401dca65 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtWidgets: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-05-021-2/+3
| | | | | | Task-number: QTBUG-98434 Change-Id: I310ea8f19d73a79d985ebfb8bfbff7a02c424360 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtWidgets: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-261-3/+3
| | | | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Change-Id: I133b80334b66e0a5ab9546dd8e1ff0631e79601e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix warning from deprecated QMouseEvent constructor on macOSVolker Hilsheimer2022-03-211-2/+2
| | | | | | | | Pass global position explicitly. Pick-to: 6.3 Change-Id: I4b9bf735635528c4a289be7db6026162d5a7aff6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Widgets: use QPlatformTheme::ButtonPressKeys for pressing buttonsNoah Davis2022-03-091-16/+17
| | | | | | | | | QComboBox is included because it works like a button when it is not editable. QGroupBox is included because it has a checkbox and QCheckBox is a subclass of QAbstractButton. Change-Id: Iad89259314e77f78c915dce83ec601df94c88941 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Doc: Remove mentioning of Fowler bookKai Köhne2022-01-171-2/+1
| | | | | | | | | It is out of print since years, and probably quite dated by now (released 1997). Pick-to: 6.3 Change-Id: I1653eb404713c15d70b8a15858e8c7d12b2e71cb Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* widgets: Fix typos in source code commentsJonas Kvinge2021-10-151-2/+2
| | | | | | Pick-to: 6.2 Change-Id: I22f71a53b0f7f0698450123343e25548c889c3e2 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QComboBox: propagate style change on widget to internal containerVolker Hilsheimer2021-05-311-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | When changing the style of the combobox, the change will not propagate to the internal container widget, so the changeEvent handler won't be called. This is correct (as per QWidget::setStyle documentation). QComboBoxPrivateContainer asks the combobox style for relevant settings, such as the frame style, which is then used for sizing and positioning. If the combobox's and container's settings become inconsistent, then the combobox popup will not get the correct size and/or position. Move some of the style-dependent changes into a separate function and call it when the QComboBox::changeEvent handles the style change so that both widgets have a consistent set of settings. Add a test case that verifies that the style is asked for the relevant setting when the style changes. Note: QComboBox does a lot of style-dependent setup work in different places, which is quite messy and complex. Trying to consolidate that further breaks tests though, so this change is doing the minimum necessary to fix the reported issue. Pick-to: 6.1 5.15 Fixes: QTBUG-92488 Change-Id: Ia957d504b2d800add26fc0565be727b5c08a5358 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QComboBox: add space for scrollbar if needed after showing popupVolker Hilsheimer2021-05-311-6/+13
| | | | | | | | | | | | | | | | | QComboBox tests if a horizontal scrollbar is needed before sizing and showing the popup, but QListView only knows whether a scrollbar is needed only after laying itself out during the initial show and paint event. So test whether the need has arisen as part of this initial layout, and then provide the additional space. Resizing the widget after showing it is not ideal, but in practice makes no visible difference (and it's either way preferable to not being able to access the item covered by the scrollbar). Pick-to: 6.1 5.15 Fixes: QTBUG-93736 Change-Id: I0bf077e18116ce174ae7f9218cb3b0dfa82964e1 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Delete duplicate condition in QComboBox::setPlaceholderTextDong Rui2021-03-091-1/+1
| | | | | | | There is a duplicate condition judgment in QComboBox::setPlaceholderText, just delete it. Change-Id: I570415c5930372866f290216a89260353d3992b7 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* Fix that the placeholdertext of QCombobox is not drawnChunLin Wang2021-01-271-2/+4
| | | | | | | | | If the current index is invalid,a placeholdertext will be displayed. Fixes: QTBUG-90595 Pick-to: 6.0 5.15.2 Change-Id: Id4c6b9c959242b96ee0944b8fc3131a9a2fdcccc Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* QComboBox: fix select all columns in the viewChristian Ehrlicher2021-01-131-2/+4
| | | | | | | | | | | | | | | When the QComboBox gets a custom view with multiple columns, only the first one is selected even the selection mode of the view is SelectRows. The selection changes afterwards properly honor the mode though. Therefore check for the selection mode and call setCurrentIndex() with the appropriate flags. Fixes: QTBUG-86776 Pick-to: 6.0 Pick-to: 5.15 Change-Id: Ieba7b9e009358e7b6e802b7847640161ec776c64 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCombobox: propagate the palette to the embedded line editWang Chuan2020-11-021-0/+1
| | | | | | | | | | Let the new created embedded QLineEdit use the palette from QCombobox, when calling [setEditable(true)] Fixes: QTBUG-81533 Pick-to: 5.15 Change-Id: Ia406dd8122a348e185f0e94d027646b95eeaa76e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Deprecate QVariant::TypeLars Knoll2020-10-231-1/+1
| | | | | | | | | It's been obsolete for a long time already. Make sure the compiler now warns about it and remove all remaining uses in qtbase. Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Another round of replacing 0 with nullptrAllan Sandfeld Jensen2020-10-071-1/+1
| | | | | | | | | This time based on grepping to also include documentation, tests and examples previously missed by the automatic tool. Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* fix QComboBox currentText return placeholderTextWang ChunLin2020-09-251-3/+2
| | | | | | | | | If it does not add item,the currentText should return empty string Fixes: QTBUG-86580 Pick-to: 5.15 Change-Id: I54c3a8b7ececfb1e62bcd7ac592feccaff3f8b48 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>