summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
Commit message (Collapse)AuthorAgeFilesLines
* Don't allocate QColorLuminancePicker::pix on the heapMichael Weghorn3 days1-9/+6
| | | | | | | | | | | | There's no reason to use a pointer for this pixmap and allocate it on the heap. Make use of the fact that a QPixmap can be a null pixmap to indicate/detect the case when no actual pixmap data are currently set. Change-Id: Ibebacfdd5ee7e8d0563197b052dde88aa8ea8c7f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Doc: Fix QDoc warnings for internal classes in Qt WidgetsJerome Pasion12 days2-0/+11
| | | | | | | | -Internal classes should have internal class documentation. Task-number: QTBUG-141665 Change-Id: I399e0cec51a9308172301a862dcd07e6137e9854 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Doc: Clarify the usage of file filters in QFileDialogAlexei Cazacov2025-11-211-54/+67
| | | | | | | | | | | | | This commit restructures and enhances the description of the file filters in QFileDialog. The commit adds info on MIME type filters and clarifies the case sensitivity of file filters on various platforms. Fixes: QTBUG-135381 Pick-to: 6.10 6.8 Change-Id: I1fa7eeefb0e242285ee3bc4a86f29b76f72abe8f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Alexei Cazacov <alexei.cazacov@qt.io>
* Build with QT_NO_URL_CAST_FROM_STRINGAhmad Samir2025-11-201-2/+0
| | | | | | | | | | | Can't mark the whole repo with that macro, because in corelib that would take out the QString conversion operator which is BiC. Add a hard build-time error if QT_NO_URL_CAST_FROM_STRING is defined in corelib, as requested in code review. Change-Id: Ia0e302a2f82b86800e84d15e86ab138f78d45e4d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QColorDialog: add out-of-bounds check for QWellArrayChristian Ehrlicher2025-11-191-1/+1
| | | | | | | | | | QWellArray which is used to display pre-defined colors did not check if the calculated row/column is inside the possible bounds. Pick-to: 6.10 6.8 Fixes: QTBUG-105476 Change-Id: Id795f825479540086b4126b633ef1889c420c714 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* a11y: Add a11y implementation for QColorWellMichael Weghorn2025-11-132-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The QColorWell widget is used to provide/present a set of predefined or custom colors in QColorDialog. So far, there was no accessibility implementation for this widget, meaning that the colors/items were completely inaccessible on the a11y layer. Introduce QAccessibleColorWell as new a11y implementation for QColorWell, and QAccessibleColorWellItem for all the color items it provides. As QColorWell arranges its items in columns (i.e. color indices 0 to QColorWell::numRows() - 1 are in first column, not 0 to QColorWell::numCols() -1 in the first row), also use the same order for the accessible children/child indices: Send a11y focus events when the focus moves between items in the QColorWell. This makes both, Orca on Linux and Narrator on Windows announce the currently focused item when navigating through the list using the keyboard. For now, use "RGB <red>, <green>, <blue>" for the accessible names of the color items (with <red>, <green and <blue> being the value for the color's RGB components), which is a form that the Orca screen reader could interpret in other contexts to speak the name of the closest known color, see [1], section "Speak colors as names". [1] https://help.gnome.org/users/orca/stable/preferences_speech.html.en Fixes: QTBUG-141571 Change-Id: I7ec64d87e6ae41070c5cb34341bbf527260cca3f Reviewed-by: MohammadHossein Qanbari <mohammad.qanbari@qt.io>
* a11y: Make QSidebar keyboard-navigableMichael Weghorn2025-11-071-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QSidebar::selectUrl calls QItemSelectionModel::clear, which clears both, the selection and the current index. After that, it was only setting the selection, but no new current index, i.e. no entry was considered as having focus. As a result, navigating between entries using the keyboard didn't work, because the logic in QAbstractItemView::keyPressEvent/QListView::moveCursor didn't have a valid index to start from and therefore always set focus to the first entry. Fix this by also setting the current index again in QSidebar::selectUrl. Move emission of the QSidebar::goToUrl signal from QSidebar::clicked down into QSidebar::selectUrl to ensure this gets called when the URL/current index is set programatically by calling QSidebar::selectUrl directly instead of indirectly via QSidebar::clicked due to user action. (As an example, tst_QFileDialog2::task251321_sideBarHiddenEntries calls this directly, and the emulated mouse click now no longer triggers the QItemSelectionModel::currentChanged signal as the current index was already set by the previous call to QSidebar::selectUrl, and therefore the connected QSidebar::clicked slot is also no longer triggered.) Adjust the existing tst_qsidebar tests related to the QSidebar::goToUrl signal to the fact that this now gets emitted from QSidebar::selectUrl. (Since QSidebar isn't part of the public API, there's no need to keep the exact semantic of when the signal gets emitted unchanged.) Also switch the test to use PMF-style syntax to e.g. simplify finding those occurences using an IDE's "Find Usages" feature in the future. Fixes: QTBUG-141644 Change-Id: I872698de81912225cd42a5df3752d2693ac6b9ee Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Don't emit QFileDialog::directoryEntered when not changing dirMichael Weghorn2025-11-071-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | In QFileDialogPrivate::enterDirectory, return early if the directory to enter is already the current directory. This prevents emitting the QFileDialog::directoryEntered signal when no new directory was actually entered. Extend tst_QFiledialog::directoryEnteredSignal accordingly. This prepares for an upcoming fix for QTBUG-141644 where the fact that QFileDialogPrivate::enterDirectory was called again with the same path resulted in the signal getting emitted twice and therefore causing the existing QCOMPARE(spyDirectoryEntered.size(), 1); check in tst_QFiledialog::directoryEnteredSignal to fail. Task-number: QTBUG-141644 Change-Id: I3359f9f8af3ce03c7b32c040a92d4bf09e065e85 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* a11y QFontDialog: Consistently set lists as buddiesMichael Weghorn2025-11-051-1/+1
| | | | | | | | | | | | | | | As is done for the "Font" and "Font style" labels, also set the corresponding list as the buddy of the "Size" label and not the line edit. This ensures consistent behavior and that the label gets announced by screen readers when using the Tab key to navigate through the dialog and the "Size" list view receives focus. Fixes: QTBUG-141703 Change-Id: Idb228a665e2f73c13516a8b4c1ebb63ba6d28b25 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* a11y: Make QColorLuminancePicker keyboard accessibleMichael Weghorn2025-11-051-0/+17
| | | | | | | | | | | Make QColorLuminancePicker (used in QColorDialog) keyboard accessible: Allow it to receive focus and adjust the value by 1 when the Up/Down key is pressed. Fixes: QTBUG-141666 Change-Id: I5a46e80dca25219f5d98c210a8a1f045ed202bf0 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* a11y: Make QColorPicker keyboard accessibleMichael Weghorn2025-11-051-0/+23
| | | | | | | | | | | | | Make QColorPicker (used in QColorDialog) keyboard accessible: Allow it to receive focus and move the position indicating the currently selected color by one pixel in the corresponding direction when one of the arrow keys is pressed. Task-number: QTBUG-141666 Change-Id: Iab724f6c576327ddec8d5f1c06f58509b5e0f4c8 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QColorPicker: Remember position, not hue and satMichael Weghorn2025-11-051-29/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of remembering the hue and saturation value and calculating those when setting a new position by using the mouse, instead do the opposite: Remember the position and calculate the hue and saturation values on demand. The motivation is that translating a position to a hue/sat value and then translating that back to a position doesn't necessarily restore the exact original position, but may result in a position that slightly differs (e.g. shifted by a pixel, because multiple pixel positions can represent the same hue/saturation values). While that's not a big deal when it results in the position getting set to one that's a pixel away from the exact position that was clicked using the mouse, it would become a problem with an upcoming commit that allows to move the position using the keyboard: Pressing/Holding an arrow key should result in the position moving in the expected direction, but that wouldn't be the case with the previous logic. (In a first attempt without this commit in place, it would result in the position moving more or less diagonally towards the top-left for the Left and Up keys, upwards for the Right arrow key and left for the Down key.) In the ctor, call base class method QWidget::adjustSize to ensure that the widget has its final (fixed) size, which allows creating the pixmap there. However, still adjust QColorPicker::resizeEvent to calculate the new position based on the hue/saturation values that can be calculated using the current position and previous widget size. (In a quick test using GammaRay [1] to manually change the widget size, this results in the position getting updated as expected, i.e. the cross is then shown at the new position of the currently selected color.) Make sure to keep the hue and saturation values within the valid range in QColorPicker::huePt and QColorPicker::satPt. Previously, QColorPicker::setCol(int, int) would take care of it, but QColorPicker::setCol(const QPoint &) no longer calls this method now, but now the former calls the latter. Therefore, move some logic from the former to the latter so it still gets run in both cases. Keep previous logic to not emit the QColorPicker::newCol signal when the QColorPicker::setCol(int, int) setter gets called as the QColorDialog implementation relies on that. [1] https://github.com/KDAB/GammaRay Task-number: QTBUG-141666 Change-Id: I72d9cfd8920e4b608baa07c5728ee358eee55823 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QColorPicker: Move signal emission to QColorPicker::setColMichael Weghorn2025-11-051-2/+1
| | | | | | | | | | | | | | Instead of emitting the signal in both callers of the QColorPicker::setCol variant taking a QPoint, emit the signal from that method. This also prepares for further uses of the method in an upcoming commit without having to take care of manually emitting the signal in those as well. Task-number: QTBUG-141666 Change-Id: I2a373ebdb983e458d8393effc13bc4abf582fb25 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* a11y: Set buddies in QFileDialogMichael Weghorn2025-11-041-2/+8
| | | | | | | | | | | | | | | | | This allows quickly navigating to the combo boxes labelled by the "Look in:" and "Files of type:" labels and makes sure the accessible relations between the label and the comboboxes are set. This makes screen readers like Orca on Linux announce the label texts when the comboboxes receive focus, so the meaning of the comboboxes becomes clear. Update tst_QFiledialog::labelText to include the newly set shortcut keys in the expected label texts. Fixes: QTBUG-141641 Change-Id: I8bc156d5e8d9b337a2a7ff34fe93ff1dda393de9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Move QWellArray and QColorWell to new QtWidgetsPrivate headerMichael Weghorn2025-11-022-125/+149
| | | | | | | | | | | | Move class definitions for QColorWell and its QWellArray subclass from the source file for the QColorDialog implementation to a new private header file, in preparation of adding an accessibility implementation for QColorWell in an upcoming commit. Task-number: QTBUG-141571 Change-Id: I3df29a7338f74a31088424d5c6fcae0130b7a0a3 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* QFileDialog: Remove unused QFileDialogLineEdit::d_ptrhjk2025-10-302-5/+1
| | | | | Change-Id: Id539eaaa1e426171bd58b6c0b2a7b48a2299e010 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Drop never defined QWellArrray::cellContentMichael Weghorn2025-10-291-1/+0
| | | | | | | | | | The method is only declared, but unused and not actually implemented anywhere. Drop it. Change-Id: I9e89052789780fa7f5b87acb99ed3bea5f203bd4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Add alternate text for Qt Widgets imagesJerome Pasion2025-10-094-20/+22
| | | | | | | | | | Alternate text (alt text) improves the documentation experience for screen readers and for other accessibility tools. Pick-to: 6.9 6.10 Task-number: QTBUG-135124 Change-Id: Ic481c1468548d197a69c9e19703c5773226fbd39 Reviewed-by: Alexei Cazacov <alexei.cazacov@qt.io>
* QWidzardHeader: fix Coverity UNINIT_CTOR warningMarc Mutz2025-10-071-1/+1
| | | | | | | | | | | | | | | | Coverity complained that the constructor doesn't init the wizardBannerSizePolicy data member. The setup() function does, but such two-stage construction is of course brittle. Use NSDMI to init the variable to the documented default value (NoStretch), the same as we do in QWizardPrivate already. Amends a22cbf33a00250f6272bfabfddce993d101c6b90. Coverity-Id: 895908 Change-Id: I07c0df77fcc419e862283d68d030f38fc779a393 Reviewed-by: Xavier BESSON (Personal) <developer@xavi-b.fr> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QWizardHeader: mark the ctors explicitMarc Mutz2025-10-061-0/+2
| | | | | | | | | | Found while working in the vicinity. Amends the start of the public history. Pick-to: 6.10 6.8 6.5 Change-Id: I2df202fd18a0b80412b5f689fd0b454106adb4d8 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QWizard: make QWizardHeader a bit more safeMarc Mutz2025-10-071-1/+2
| | | | | | | | | | | | | The Ruler ctor is only used from QWizardRuler, a subclass, so mark it as protected, because it doesn't initialize any of the data members. Found while fixing a Coverity complaint in the vicinity. Amends the start of the public history. Pick-to: 6.10 6.8 6.5 Change-Id: I407940dc8f720976dec0608eae1649d088f6f98d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Allow stretching QWizard banner on ModernStyleXavier BESSON2025-09-232-5/+59
| | | | | | | | | | | | | Currently with ModernStyle, if a banner is set on page, then when reaching this page, the QWizard gets a fixed size because of layouting. This change would allow stretching the banner preventing the QWizard fixed resizing. Task-number: QTIFW-3852 Change-Id: If96285b7c3969b1377da69749fb7b8a0fac554b3 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Assess security level for files under qtbase/src/widgets/dialogsPiotr Wiercinski2025-09-1727-0/+27
| | | | | | | | | | Assign the default level to all files but qfiledialog.cpp which parses input in restoreState(). Fixes: QTBUG-135735 Pick-to: 6.10 6.9 6.8 Change-Id: I27e1f18e26e070130018ccf6fa47ccf78b635dc8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QDialog: Add missing attribute set for explicit hide and showMorteza Jamshidi2025-09-081-6/+1
| | | | | | | | | | | | | | Due to setVisible function being overrided in the QDialog and after this commit 79be5fa98663ca6b7e905ecb08950f17ccc06e98, the logic for setting WA_WState_ExplicitShowHide attribute was never called. It seems like that's the only logic missing from QWidget::setVisible function so instead of adding the logic here, we call the base function. Fixes: QTBUG-139291 Change-Id: I287b4daca3cd682a20aeb8bf4b5ada7eeab2ab19 Pick-to: 6.10 6.9 6.8 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Doc: Update QDialog and QMessageBoxDheerendra Purohit2025-07-111-0/+4
| | | | | | | | | Improve the documentation for QDialog and QMessageBox. Clarifies example usage and the optional nature of the parent parameter without implying a required guideline. Fixes: QTBUG-123902 Change-Id: I30749a0c13de55f41ce9c944542cf3c6356fd6bd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* make all convenience functions in QFileDialog open modal dialogsNic Zonta2025-06-061-2/+2
| | | | | | | | | | most convenience functions in qfiledialog.cpp (e.g. getSaveFileUrl, getOpenFileUrl) open modal dialogs, with the exception of getOpenFileContent and saveFileContent. This makes every function consistently open modal dialogs Fixes: QTBUG-137329 Pick-to: 6.10 6.9 Change-Id: I48952144ed15596b9acba3230c63cece613fb045 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QColorDialog: Stop color picking when application is deactivatedFriedemann Kleint2025-06-051-0/+10
| | | | | | | Fixes: QTBUG-134143 Pick-to: 6.10 Change-Id: Ibfeff4f861ac5c63f4bdd85db40b25eee51c4d31 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Doc: Fix broken links in Qt WidgetsKai Köhne2025-06-031-1/+1
| | | | | | | | | The iQRhiWidget API got changed in commits acebb97b5880, acebb97b58807d1d591. Pick-to: 6.8 6.9 6.10 Change-Id: I7791b1a61d94f33ba01cfe22e63ecfdc7b81022b Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Widgets: pass dpr to QIcon::pixmap()Christian Ehrlicher2025-04-232-3/+6
| | | | | | | | | Replace the last occourences of QIcon::pixmap() which do not pass the current devicePixelRatio with the correct calls. Pick-to: 6.9 Change-Id: I440944f784a991a88a8c6bb42e4c79f112bab8f6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix -no-feature-draganddrop buildsOliver Eftevaag2025-04-101-0/+2
| | | | | | | | Building tests will still cause build issues, but at least this lets you build without them. Change-Id: Iea5c93bf31593a5ee0f66c877da4d5a7ba9b6dc3 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* QErrorMessage: fix UB (invalid cast) in Private::setVisible()Marc Mutz2025-03-281-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function can be called from ~QDialog(), in which case a cast of q_ptr to QErrorMessage is UB. Says UBSan: errormessage.cpp:33:5: runtime error: downcast of address 0x7fff5089a6e0 which does not point to an object of type 'QErrorMessage' 0x7fff5089a6e0: note: object is of type 'QDialog' 00 00 00 00 30 74 4e 6a 12 7f 00 00 80 aa 00 00 90 61 00 00 08 76 4e 6a 12 7f 00 00 00 00 e0 1a ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QDialog' #0 0x7f1267ce7d12 in QErrorMessagePrivate::q_func() qerrormessage.cpp:33 #1 0x7f1267ce7d12 in QErrorMessagePrivate::setVisible(bool) qerrormessage.cpp:410 #2 0x7f1267caaa25 in QDialog::setVisible(bool) qdialog.cpp:757 #3 0x7f12654efb28 in QWidget::hide() qwidget.cpp:8179 #4 0x7f1267caa239 in QDialog::~QDialog() qdialog.cpp:398 #5 0x7f1267ce72f8 in QErrorMessage::~QErrorMessage() qerrormessage.cpp:287 Fix by casting at most to QDialog* (QWidget* would actually have sufficed). Add a code comment. Amends e0bb9e81ab1a9d71f2893844ea82430467422e21 (I think; it might have been present in a different form before that). Pick-to: 6.9 6.8 6.5 Change-Id: I61a8692f073c2d2f379ea02fa580f7fe46691c1c Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QFileDialog: fix UB (invalid cast) in Private::setVisible()Marc Mutz2025-03-261-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function can be called from ~QDialog(), in which case a cast of q_ptr to QFileDialog is UB. Says UBSan: qfiledialog_p.h:78:5: runtime error: downcast of address 0x7ffe7a8ad5a0 which does not point to an object of type 'QFileDialog' 0x7ffe7a8ad5a0: note: object is of type 'QDialog' fe 7f 00 00 30 44 d8 fb d2 7f 00 00 80 b4 00 00 90 61 00 00 08 46 d8 fb d2 7f 00 00 00 00 00 00 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QDialog' #0 0x7fd2f96d7587 in QFileDialogPrivate::q_func() qfiledialog_p.h:78 #1 0x7fd2f96d7587 in QFileDialogPrivate::setVisible(bool) qfiledialog.cpp:860 #2 0x7fd2f95465f5 in QDialog::setVisible(bool) qdialog.cpp:757 #3 0x7fd2f6d88768 in QWidget::hide() qwidget.cpp:8179 #4 0x7fd2f9545e09 in QDialog::~QDialog() qdialog.cpp:398 Fix by casting to QFileDialog only on show() (in createWidgets()), not hide(), and otherwise cast at most to QDialog* (QWidget* would actually have sufficed). Add a code comment. Amends e0bb9e81ab1a9d71f2893844ea82430467422e21 (I think; it might have been present in a different form before that). Pick-to: 6.9 6.8 6.5 Change-Id: I4e206f7c36c03e8cb8a36001beae283628960073 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QFontDialog: fix UB (invalid cast) in Private::setVisible()Marc Mutz2025-03-251-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function can be called from ~QDialog(), in which case a cast of q_ptr to QFontDialog is UB. Says UBSan: qfontdialog_p.h:43:5: runtime error: downcast of address 0x604000026b90 which does not point to an object of type 'QFontDialog' 0x604000026b90: note: object is of type 'QDialog' 00 00 00 00 30 a4 26 31 45 7f 00 00 80 b9 00 00 90 61 00 00 08 a6 26 31 45 7f 00 00 00 00 be be ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QDialog' #0 0x7f452ecad24d in QFontDialogPrivate::q_func() qfontdialog_p.h:43 #1 0x7f452ecad24d in QFontDialogPrivate::setVisible(bool) qfontdialog.cpp:959 #2 0x7f452ea2b5f5 in QDialog::setVisible(bool) qdialog.cpp:757 #3 0x7f452c26d768 in QWidget::hide() qwidget.cpp:8179 #4 0x7f452ea2ae09 in QDialog::~QDialog() qdialog.cpp:398 Fix by casting at most to QDialog* (QWidget* would actually have sufficed). Add a code comment. Amends e0bb9e81ab1a9d71f2893844ea82430467422e21 (I think; it might have been present in a different form before that). Pick-to: 6.9 6.8 6.5 Change-Id: Ic1a63ff02b1a1435499a6980772b1b75236f31f7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QColorDialog: fix UB (invalid cast) in Private::setVisible()Marc Mutz2025-03-251-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function can be called from ~QDialog(), in which case a cast of q_ptr to QColorDialog is UB. Says UBSan: qcolordialog.cpp:72:5: runtime error: downcast of address 0x7ffd37909750 which does not point to an object of type 'QColorDialog' 0x7ffd37909750: note: object is of type 'QDialog' fd 7f 00 00 30 34 6e 35 4a 7f 00 00 80 b9 00 00 90 61 00 00 08 36 6e 35 4a 7f 00 00 00 00 f2 a6 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QDialog' #0 0x7f4a32e8738a in QColorDialogPrivate::q_func() qcolordialog.cpp:72 #1 0x7f4a32e8738a in QColorDialogPrivate::setVisible(bool) qcolordialog.cpp:2154 #2 0x7f4a32ea5675 in QDialog::setVisible(bool) qdialog.cpp:757 #3 0x7f4a306e7768 in QWidget::hide() qwidget.cpp:8179 #4 0x7f4a32ea4e89 in QDialog::~QDialog() qdialog.cpp:398 Fix by casting to Qcolordialog only on show() (in initWidgets()), not hide(), and otherwise cast at most to QDialog* (QWidget* would actually have sufficed). Add a code comment. Amends e0bb9e81ab1a9d71f2893844ea82430467422e21 (I think; it might have been present in a different form before that). Pick-to: 6.9 6.8 6.5 Change-Id: I006406b6cf1012fc3c7a910abcfe14bc119a2b29 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QMessageBox: fix UB (invalid cast) in Private::setVisible()Marc Mutz2025-03-251-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function can be called from ~QDialog(), in which case a cast of q_ptr to QMessageBox is UB. Says UBSan: qmessagebox.cpp:182:5: runtime error: downcast of address 0x7ffdccfbda00 which does not point to an object of type 'QMessageBox' 0x7ffdccfbda00: note: object is of type 'QDialog' 88 7f 00 00 30 94 4a 73 88 7f 00 00 80 8c 00 00 90 61 00 00 08 96 4a 73 88 7f 00 00 00 00 fb cc ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QDialog' #0 0x7f8870f9a8a3 in QMessageBoxPrivate::q_func() qmessagebox.cpp:182 #1 0x7f8870f9a8a3 in QMessageBoxPrivate::setVisible(bool) qmessagebox.cpp:1660 #2 0x7f8870c6b3b5 in QDialog::setVisible(bool) qdialog.cpp:757 #3 0x7f886e4ad4b8 in QWidget::hide() qwidget.cpp:8179 #4 0x7f8870c6abc9 in QDialog::~QDialog() qdialog.cpp:398 Fix by casting to QMessageBox only on show(), not hide(), and otherwise cast at most to QDialog* (QWidget* actually suffices). Add a code comment. Amends e0bb9e81ab1a9d71f2893844ea82430467422e21 (I think; it might have been present in a different form before that). Pick-to: 6.9 6.8 6.5 Change-Id: Ia163483c1998924a0d9c9fd589311af24a93d1fe Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QMessageBox: really fix UB (invalid cast) in Private::canBeNativeDialog()Marc Mutz2025-03-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The code comment above the cast is correct, but the code wasn't: While we're receiving the result of the cast in a QDialog pointer, the cast is still to QMessageBox*, and whether that cast is in the Q_Q macro or not doesn't change the fact that it's invalid. Says UBSan: qmessagebox.cpp:2804:31: runtime error: downcast of address 0x7ffebfd87140 which does not point to an object of type 'QMessageBox' 0x7ffebfd87140: note: object is of type 'QDialog' 2b 7f 00 00 30 94 57 b9 2b 7f 00 00 80 8c 00 00 90 61 00 00 08 96 57 b9 2b 7f 00 00 00 00 d8 bf ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QDialog' The trivial fix is to cast only to QDialog. Amends 29b2506e8cf0c792821a3ddb28e62080cd66ae28. Pick-to: 6.9 6.8 Change-Id: Ia3f6c08b62f6bed274f43baab881a0d802bd986b Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
* Docs: fix typoMoss Heim2025-03-121-1/+1
| | | | | | | | | | \l instead of \\l Amends d3117e97014af029b2c117daef9695b87103ab25. Pick-to: 6.9 6.8 6.5 Change-Id: I0b6aaef6de839f29e0671d382d4555f8ab0afe47 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use QThread::isMainThread() in a few placesThiago Macieira2025-02-261-1/+1
| | | | | | | | | | | | | | | It's thread-safe, whereas trying to load qApp isn't in Qt 6.x (will be in 7.0) and dereferencing it to call QObject::thread() will probably never be. It's also faster, being a single function call instead of two or three. This is not an exhaustive search, it's just a few places I found while searching for QThread::instance(). Pick-to: 6.9 6.8 Change-Id: I3b4e1c75bb3966e2cd2dfffd79bfc8a40f6cf40b Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QWizard: Drop obsolete sentence in QWizard::currentId docMichael Weghorn2025-02-241-3/+0
| | | | | | | | | | | Commit 2140edaaab0bf61f354db521efca773568becc56 introduced QWizard::setCurrentId that allows setting the property directly, so drop the obsolete sentence in the QWizard::currentId doc stating that this isn't possible. Pick-to: 6.9 6.8 6.5 Change-Id: I5e7da2323e66a6e8bfd653dfebcba4363023b744 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QFileDialog: the lastVisited not loaded correctlyShitong Xu2025-01-211-4/+11
| | | | | | | | | | | | | | | | | Url passed from the QFileDialogArgs will never be invalid, it will always be the value that user passed into or the lastVisited or the working directory. And because of this, the fixes code of QTBUG-70798 will never be invoked, and the `lastVisited` will never be initialize if nativedialog is in use. I wrote an init function to initialize the `lastVisited` global variable, to make sure the value will be loaded correctly Fixes: QTBUG-70798 Pick-to: 6.8 6.9 Change-Id: Id05f63db7b4738e6317721741111882a565437e3 Reviewed-by: Xu Shitong <xushitong@uniontech.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Doc: Add setModel(open) option to the documentationJaishree Vyas2025-01-171-16/+24
| | | | | | | | | Changed the Model Dialogs section adding open() function. Task-number: QTBUG-127777 Pick-to: 6.8 6.9 Change-Id: If5086f4e2226c4d032fe1bcfbf2ef550803973c8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove unused qdebug.h include from private headersAhmad Samir2025-01-161-1/+0
| | | | | | Pick-to: 6.9 Change-Id: I03c951d03ab2410298878d0689c0d50bdd4eedf2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Replace qgetenv() calls converted to QString with qEnvironmentVariable()Thiago Macieira2025-01-011-2/+2
| | | | | | | | It's slightly more efficient. Pick-to: 6.9 Change-Id: Id5ac04fc27eee108c8e5fffd786c3d5f793a0a9d Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Widgets: pass dpr to QIcon::pixmap()Christian Ehrlicher2024-12-291-2/+1
| | | | | | | | | Change the remaining calls to QIcon::pixmap() to pass a valid devicePixelRatio parameter. Pick-to: 6.9 Change-Id: I0e71e20c8109e296446e9e13cddba31d53c05df9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Guard the usages of QPlatformIntegration::services()Liang Qi2024-11-251-1/+1
| | | | | | | Task-number: QTBUG-130884 Pick-to: 6.8 6.5 Change-Id: I6c8060ce8b7a4e525c46e2e1fec227f46fe8c4d6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QFileDialog: disconnect nativeEnterDirectory in dtorTimur Pocheptsov2024-10-181-1/+7
| | | | | | | | | | | | QIOSFileDialog emits directoryEntered from its hide/setVisible after QFileDialog is a QDialog already (in the process of destruction). This results in an ssert: "ASSERT failure in QFileDialog: "Called object is not of the correct type (class destructor may have already run)"", Fixes: QTBUG-130133 Pick-to: 6.8 Change-Id: I8471a8434f7ea854a91b989bb3a6f3b962143ea8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* Docs: Update the screenshots for the Qt Widgets examplesAlexei Cazacov2024-10-111-1/+1
| | | | | | | | | | This commit updates the screenshots for the Qt Widget examples. It also removes several unused screenshots and adds several minor edits. Task-number: QTBUG-69988 Pick-to: 6.8 Change-Id: I23b90fd6c8b798169d158854609c09ef3f1c1a20 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* tests: Explicitly check for pathconf(_PC_CASE_SENSITIVE) == 1Tor Arne Vestbø2024-09-231-1/+1
| | | | | | | | | | | | | | | | We use pathconf in some of our tests to determine if the file system on Darwin is case sensitive. But pathconf returns -1 if the case sensitivity can't be determined, with errno set to ENOTSUP. The convention in this case is to treat the file system as not being case sensitive (as reported by NSURLVolumeSupportsCaseSensitiveNamesKey and VOL_CAP_FMT_CASE_SENSITIVE in equivalent APIs), so we need to check explicitly for a return value of 1. Pick-to: 6.8 Change-Id: I1107e849babd8813da3b148c92494e8e35a32d36 Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDialogs: prevent crash in static get*() functions when parent gets deletedTatiana Borisova2024-09-144-65/+51
| | | | | | | | | | | | | | | | | | | | | | | | - As explained in https://blogs.kde.org/2009/03/26/how-crash-almost-every-qtkde-application-and-how-fix-it-0 creating dialogs on the stack is a bad idea, if the application or the dialog's parent window can be closed by means other than user interaction (such as a timer or an IPC call). Since we cannot know whether Qt is used to build such an application, we must assume it is, create the dialog on the heap, and monitor its lifetime with a QPointer. Long time ago instead of using manual resource management, QAutoPointer was added to fix the crash problem for QInputDialog. The same fix now is being applied for the rest of QDialog classes: QColorDialog, QFileDialog, QFontDialog. Documentation warnings about deleting the parent are not actual anymore. Deleted. Task-number: QTBUG-54693 Change-Id: Ib7cc0575ea25f392a295538e21de9015dc49ebe4 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Doc: Remove usage of defunct QDoc commandPaul Wicking2024-08-281-4/+0
| | | | | | | | | | | | | | The QDoc command `\tableofcontents` was rendered useless by a change more than a decade ago. Remove the use of `\tableofcontents` as it serves no purpose, and ensure that the surrounding context still makes sense for the reader, by removing preceding text that refers to a non-existing table of contents, such as `Contents:`. Task-number: QTBUG-128173 Pick-to: 6.8 Change-Id: Ibb5a6af0e80f70fa487cdf6a7e38009a9ef60cbf Reviewed-by: Safiyyah Moosa <safiyyah.moosa@qt.io> Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>