summaryrefslogtreecommitdiffstats
path: root/examples/widgets
Commit message (Collapse)AuthorAgeFilesLines
* Regular Expression example: Brush up and add a way to preview replacementsFriedemann Kleint2021-06-023-27/+99
| | | | | | | | | | | | | - Set a fixed font on text edits so that parentheses stand out - Rearrange the layout to have the text at the top be prevent long texts from being wrapped - Add a replacement field where one can exercise replacement with the \1, \2... placeholders. Change-Id: I140a62e1fb2cd1c6bfe02a2f01b7f06a6f3b5eb2 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 6ac77e81aec0b48a76b385092d9050941fa0e257) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix BASE argument of qt_add_resourcesJoerg Bornemann2021-05-1810-1400/+350
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The BASE argument of qt_add_resources now denotes the root point of the alias of the file. Before, BASE was merely prepended to every file that got passed to qt_add_resources. Old behavior: qt_add_resources(app "images" PREFIX "/" BASE "../shared" FILES "images/button.png") Alias is "../shared/images/button.png", and pro2cmake generated QT_RESOURCE_ALIAS assignments to fix this. New behavior: qt_add_resources(app "images" PREFIX "/" BASE "../shared" FILES "../shared/images/button.png") The alias is "images/button.png". No extra QT_RESOURCE_ALIAS assignment is needed. The new behavior is in effect for user projects and for Qt repositories that define QT_USE_FIXED_QT_ADD_RESOURCE_BASE. Qt repositories will be ported one by one to this new behavior. Then the old code path can be removed. Task-number: QTBUG-86726 Change-Id: Ib895edd4df8e97b54badadd9a1c34408beff131f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 92185d417de43237ae62eae55599c65922cd9a15) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Brush up the text edit exampleFriedemann Kleint2021-05-182-82/+67
| | | | | | | | | | | | | | | - Use initializer lists - Use u instead of QLatin1String() - Fix some clang warnings about else after return, constFirst() - Streamline code - Remove slot TextEdit::printPreview() which is not needed - Rename variable fileName to pdfFileName in filePrintPdf() to disambiguate from this->fileName Change-Id: I377ebfd13487470b6f8eaf568dd5d99354f761f2 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 18aad6da87a329ddf7ca7c92bf2371628220fb4f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Style sheet example: Fix doc url for Qt 6Friedemann Kleint2021-05-071-2/+4
| | | | | | | Change-Id: I5c66b472b1687eec0ed1109ce2723d747b1a4193 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit e3141d5507ba9276a5f154415e013fd66875c390) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Rewrite the fetchmore exampleFriedemann Kleint2021-04-245-55/+89
| | | | | | | | | | | | | | - Start in root folder so that large directories (/bin/, Windows) are easily reachable - Remove the line edit and navigate by double clicking instead since this is more in line with expectations - Use a QPlainTextEdit for logging - Make the log message more informative - Add icons Change-Id: Ia3cd7fc143efef80772923291f0b711913aa47be Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 2393a40ccd455cc2dca410e8a1830856dbfde12d)
* Avoid divide-by-zero in the gradients exampleShawn Rutledge2021-04-191-0/+2
| | | | | | | | | | | | | After 7a738daa97436478a21b5dd31ba2312b2cb2df41 we require QLineF::setLength() to take a finite length, and this code was probably always risky when HoverPoints has two points that are both 0,0. It's probably a transient condition anyway. Fixes: QTBUG-92908 Change-Id: If81122d2f78761026b0d656ceffe173132751317 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit 76537c065aea1cb3926796f6a34eb39eb81f605f) Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* standarddialogs example: Fix font handlingFriedemann Kleint2021-04-071-1/+7
| | | | | | | | | | | The example crashed since it passed the font label text (which receives the font key) to the QFont constructor taking the family list. Use QFont::fromString() instead. Change-Id: I499fc9200b4d817b10c946a7b79ede4e7f7e69af Reviewed-by: Andy Shaw <andy.shaw@qt.io> (cherry picked from commit c10159a9a1254992867242897adb19ae1c3c3c35) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Fix various documentation issuesTopi Reinio2021-04-071-3/+3
| | | | | | | | | | | - Document QIODeviceBase - Document QPointerEvent::points - Fix linking issues Task-number: QTBUG-90662 Change-Id: Ib123d5708953b22e01f95c82626b39a49fff95b2 Reviewed-by: Nico Vertriest <nico.vertriest@qt.io> (cherry picked from commit 00e10f62b55626097e94a2d70a9214c0062fbcd5)
* Brush up the imageviewer exampleFriedemann Kleint2021-03-302-4/+5
| | | | | | | | | | | | - Fix the save as file dialog being in "Open" mode by setting acceptMode - Fix clazy warnings about detaching QList by using constFirst() - Fix clazy warning about passing a context to slot connection Change-Id: I0c800e9829e118fcec477322aa2a13660e3b51d2 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit fe1ef3ebcbfe017bdb01e16480a5c38cad6e39b9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* dirview example: Show file icons on WindowsFriedemann Kleint2021-02-211-0/+2
| | | | | | | | | Use QFileIconProvider from QtWidgets. Task-number: QTBUG-66177 Change-Id: I22db2f8671c64d90c45ff7160af9a6925d1cecea Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 060fceb2ab7f39d04d977146db2e5f990804e398)
* UndoFramework example: make the background visibleIvan Solovev2021-01-111-0/+0
| | | | | | | | | | | | Existing background image was not displayed correctly due to scaling (see the description in related Jira task). This commit increases the thickness of the lines, so that the grid is displayed correctly Task-number: QTBUG-89896 Pick-to: 6.0 5.15 Change-Id: Iaa8218a5e9852adbc40715e86862ac3b34e1fbec Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Update Drop Site Example docs: mention the new markdown supportShawn Rutledge2020-12-011-1/+4
| | | | | | | Amends 4edcea762d9ce334c4c1a78234c90c118b81da87 Change-Id: Ide3e7a67b6604d07b76edcfe484c8d29e4e848fb Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix documentation links to High DPI documentationAndreas Buhr2020-12-011-1/+1
| | | | | | | | | | | The documentation on High DPI was recently rewritten, renaming several sections. This patch fixes the links which were broken by this change. Task-number: QTBUG-88533 Pick-to: 6.0 Change-Id: I5e9417554270a6740986d7cec5e3433d043e5560 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Rename Application ExampleVolker Hilsheimer2020-11-263-6/+6
| | | | | | | | | | Prefix it with "Qt Widgets -" to make it a bit clearer in the list of highlighted examples which module this one is about. Pick-to: 6.0 6.0.0 Change-Id: I0bf65b02db72173f1adfe0bcf8657be7905dbd6c Reviewed-by: Tuukka Turunen <tuukka.turunen@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* i18n example: No longer ignore return value of QTranslator.load()Friedemann Kleint2020-11-191-4/+9
| | | | | | | | Adapt to qtbase/86ebe46f591d33dc76e2f764524c988dd72f4437. Change-Id: Ie45d43b3eabe60195622d69458e3d881139f9ce1 Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Fix documentation warnings for Qt WidgetsTopi Reinio2020-11-121-48/+0
| | | | | | | | | | - Exclude forwarding headers to Qt GUI as they caused the headers to be parsed twice. - Drop documentation for removed example Task-number: QTBUG-86295 Change-Id: I08eb46b7c7f813f103cc545f931896be99a3ccec Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Support the markdown underline extensionShawn Rutledge2020-11-071-4/+6
| | | | | | | | | | | | | | | | MarkdownDialectGitHub now includes this feature, so *emph* is italicized and _emph_ is underlined. This is a better fit for QTextDocument capabilities; until now, _underlined_ markdown could be read, but would be rendered with italics, because in CommonMark, *emphasis* and _emphasis_ are the same. But QTextMarkdownWriter already writes underlining and italics distinctly in this way. [ChangeLog][QtGui][Text] By default (with MarkdownDialectGitHub), markdown _underline_ and *italic* text styles are now distinct. Fixes: QTBUG-84429 Change-Id: Ifc6defa4852abe831949baa4ce28bae5f1a82265 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix a bunch of qdoc warningsVolker Hilsheimer2020-11-062-4/+4
| | | | | | | Remove or fix references to removed APIs, and some qdoc syntax fixes. Change-Id: I67d71062cd7a29f4eb74b02199b1482af5e59fc0 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Add multi key bindings to QShortcutAllan Sandfeld Jensen2020-11-041-1/+1
| | | | | | | | | | | This makes it feature comparable with QAction, and makes it possible to use as a backend for QAction, and fixes a few missing alternative keybindings in qtwidgets. Change-Id: Iaefc630b96c4743fc5ef429dc841870ddd99fc64 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Get rid of all instance usage of QFontDatabaseVolker Hilsheimer2020-11-033-12/+8
| | | | | | | | All QFontDatabase APIs are static, use them accordingly. Task-number: QTBUG-88114 Change-Id: I0e4a7508646037e6e2812611262eed8b6d7ad3de Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* DropSite example: support markdownShawn Rutledge2020-11-022-0/+5
| | | | | | | | | | | | | If the mime data includes text/markdown, display it decoded in the QLabel, and also display the raw markdown in the table below. QLabel supports markdown since 51cbd5288c85cb4de382cb23d6f5559c2b626126. Ideally we should add proper support for markdown to QMimeData, but it's too late to do that for Qt 5. Pick-to: 5.15 Change-Id: I2a9998e4b239658fe49f39786e7c4fdd0c08b21a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* CMake: Fix painting examples to build as standalone projectsAlexandru Croitor2020-10-277-51/+332
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The examples use an intermediate object library to avoid duplicate file compilation. The examples worked when built as part of Qt because the shared directory was always added, and Qt::OpenGL is available implicitly. Change each project to add_subdirectory(../shared) if the object library is not available, thus making the examples build as standalone projects. Call find_package inside the shared project, to ensure the Qt packages are found. Create an alias called 'painting_shared::painting_shared' and link against that to ensure that any failure is caught at configure time rather than build time. Adapt the pathstroke example to use the object library. Comment out the code for the OpenGL scopes, because it's handled by the object library. Make sure the OpenGL dependency is public. Make sure to run moc and compile the OpenGL specific files as well. Task-number: QTBUG-87444 Change-Id: Ib0ecb68948581c5267ca04f19d8043fa44ff3d54 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Regenerate examples to set the WIN32_EXECUTABLE propertyAlexandru Croitor2020-10-27165-0/+660
| | | | | | | | | As well as the MACOSX_BUNDLE properties as necessary. Task-number: QTBUG-87664 Task-number: QTBUG-86827 Change-Id: I7677449a26d51fa853bd67bab6b3b61afbd2b12f Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Regenerate examples to use qt_add_executableAlexandru Croitor2020-10-19161-165/+185
| | | | | | Task-number: QTBUG-87661 Change-Id: I0dacfdc97a3fb7d88da85b67800f2c1b084d869b Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Brush up the basicsortfiltermodel exampleFriedemann Kleint2020-10-141-1/+25
| | | | | | | | - Add a clear button to the line edit - Indicate invalid regular expressions Change-Id: I1dbeaa0f9168224ccb9134c0c1fe281da14dcbce Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Use QScroller in the Dir View exampleShawn Rutledge2020-10-142-3/+13
| | | | | | | | | | | We have never had enough examples that show how easy it is to install a QScroller. In this case, one line makes a QTreeView flickable. Pick-to: 5.15 Task-number: QTBUG-86090 Change-Id: Idb8b4709617befb261f3b78d63ddbdaf5ad18d6b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Another round of replacing 0 with nullptrAllan Sandfeld Jensen2020-10-078-8/+8
| | | | | | | | | 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>
* Convert a couple of APIs to use viewsLars Knoll2020-10-061-1/+1
| | | | | | | | | | | Try to get rid of APIs that use raw 'const {char, QChar} *, length' pairs. Instead, use QByteArrayView or QStringView. As QStringConverter is a new class, simply change the API to what we'd like to have. Also adjust hidden API in QStringBuilder and friends. Change-Id: I897d47f63a7b965f5574a1e51da64147f9e981f6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Stylesheet example: Get rid of auto-connection slotsAlexander Volkov2020-09-253-16/+21
| | | | | Change-Id: I55d89cf33e5f9c8aef3a3dfbbdcd212415d35bcb Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* CMake: Regenerate projectsAlexandru Croitor2020-09-221-3/+0
| | | | | | | | | Clean up the state of the projects, before changing the internal CMake API function names. Task-number: QTBUG-86815 Change-Id: I90f1b21b8ae4439a4a293872c3bb728dab44a50d Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Deprecate implicit QPixmap conversion to QBitmapVolker Hilsheimer2020-09-171-1/+1
| | | | | | | | | | | | | | | | It is lossy, so should be requested explicitly, using a dedicated fromPixmap factory function. Deprecate the constructor and assignment operator, and make the constructor explicit. [ChangeLog][QtGui][QBitmap] Implicitly constructing and assigning to a QBitmap from a QPixmap has been deprecated, and the respective constructor has been made explicit. Use the fromPixmap factory function instead. Change-Id: I68ce85b26c901415137b664a1db687021d48bae0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Make QStringList an alias to QList<QString>Lars Knoll2020-09-122-2/+0
| | | | | | | | | | | | | | | | | | Fix our API, so that QStringList and QList<QString> are the same thing. This required a bit of refactoring in QList and moving the indexOf(), lastIndexOf() and contains() method into QListSpecialMethods. In addition, we need to ensure that the QStringList(const QString&) constructor is still available for compatibility with Qt 5. Once those two are done, all methods in QStringList can be moved into QListSpecialMethods<QString>. Change-Id: Ib8afbf5b6d9df4d0d47051252233506f62335fa3 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Rename QLibraryInfo::location() to path()Lars Knoll2020-09-125-5/+5
| | | | | | | | As per ### Qt6 comment. Also rename the LibraryLocation enum to LibraryPath. Change-Id: I556025a19c5bcdf2ff52598eaba32269522d4128 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove obsolete APIs and comments from QAbstractPrintDialogVolker Hilsheimer2020-09-102-2/+2
| | | | | | | | | | | | | Merging QAbstractPrintDialog with QPrintDialog, as proposed in the removed comment, seems to have little value, given that the platform specific implementations rely on the current abstraction. Adjust examples and tests; with the QAbstractPrintDialog test now testing the QPrintDialog::options API, the corresponding test function can be removed from the QPrinter test. Change-Id: Ia8906627898332e8590ea9b27e3d71dfcc6e8d71 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Port from devicePixelRatioF() to devicePixelRatio()Morten Johan Sørvig2020-09-105-8/+8
| | | | | | | This ports all of QtBase. Change-Id: If6712da44d7749b97b74f4614a04fac360f69d9e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Deliver Quit event when calling QCoreApplication::quit()Tor Arne Vestbø2020-09-072-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of QCoreApplication::quit() directly calling exit(0), which would leave QGuiApplication and client code out of the loop, we now send the Quit event, and let it pass through event delivery, before finally ending up in QCoreApplication::event(), where we call exit(0). This has the advantage that QGuiApplication can ensure all windows are closed before quitting, and if any of those windows ignore the close event the quit will be aborted. This aligns the behavior of synthetic quits via QCoreApplication::quit() with spontaneous quits from the platform via QGuiApplicationPrivate::processApplicationTermination. Clients who wish to exit the application without any event delivery or potential user interaction can call the lower level exit() function directly. [ChangeLog][QtGui] Application termination via qApp->quit() will now deliver Quit events to the application, which in turn will result in application windows being closed as part of the application quit, with an option to cancel the application quit by ignoring the close event. Clients who explicitly want to exit the application without any user interaction should call QCoreApplication::exit() explicitly. Task-number: QTBUG-45262 Task-number: QTBUG-33235 Task-number: QTBUG-72013 Task-number: QTBUG-59782 Change-Id: Id4b3907e329b9ecfd936fe9a5f8a70cb66b76bb7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove deprecated QPrinter and QPagedPaintDevice APIsVolker Hilsheimer2020-09-042-8/+8
| | | | | | | | | | | Adjusting the QPrinter test case - some use cases no longer exist, or are already tested in QPageSize and QPageLayout tests. Adjust examples and manual tests. Change-Id: I01cbc65f3d8031aea2dac86dd942126ba708b111 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Long live QKeyCombination!Giuseppe D'Angelo2020-09-033-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | C++20 via P1120 is deprecating arithmetic operations between unrelated enumeration types, and GCC 10 is already complaining. Hence, these operations might become illegal in C++23 or C++26 at the latest. A case of this that affects Qt is in key combinations: a QKeySequence can be constructed by summing / ORing modifiers and a key, for instance: Qt::CTRL + Qt::Key_A Qt::SHIFT | Qt::CTRL | Qt::Key_G (recommended, see below) The problem is that the modifiers and the key belong to different enumerations (and there's 2 enumerations for the modifier, and one for the key). To solve this: add a dedicated class to represent a combination of keys, and operators between those enumerations to build instances of this class. I would've simply defined operator|, but again docs and pre-existing code use operator+ as well, so added both to at least tackle simple cases (modifier + key). Multiple modifiers create a problem: operator+ between them yields int, not the corresponding flags type (because operator+ is not overloaded for this use case): Qt::CTRL + Qt::SHIFT + Qt::Key_A \__________________/ / int / \______________/ int Not only this loses track of the datatypes involved, but it would also then "add" the key (with NO warnings, now its int + enum, so it's not mixing enums!) and yielding int again. I don't want to special-case this; the point of the class is that int is the wrong datatype. Everything works just fine when using operator| instead: Qt::CTRL | Qt::SHIFT | Qt::Key_A \__________________/ / Qt::Modifiers / \______________/ QKeyCombination So I'm defining operator+ so that the simple cases still work, but also deprecating it. Port some code around Qt to the new class. In certain cases, it's a huge win for clarity. In some others, I've just added the necessary casts to make it still compile without warnings, without attempting refactorings. [ChangeLog][QtCore][QKeyCombination] New class to represent a combination of a key and zero or more modifiers, to be used when defining shortcuts or similar. [ChangeLog][Potentially Source-Incompatible Changes] A keyboard modifier (such as Qt::CTRL, Qt::AltModifier, etc.) should be combined with a key (such as Qt::Key_A, Qt::Key_F1, etc.) by using operator|, not operator+. The result is now an object of type QKeyCombination, that stores the key and the modifiers. Change-Id: I657a3a328232f059023fff69c5031ee31cc91dd6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove "fallback session management"Andreas Hartmetz2020-09-011-1/+0
| | | | | | | | | | | | | | With the Qt6 compatibility break, it can finally be removed. Closing windows (which might quit the application with quitOnLastWindowClosed() true, the default) acted contrary to the documentation of the commitDataRequest() signal, which could have been a hint. This removes the workaround API from the fix for QTBUG-49667 and also removes the problematic feature that it worked around. Change-Id: I672be58864ef062df7fb7f2a81658b92c4feedd2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Deprecate and remove uses of AA_DisableHighDpiScalingTor Arne Vestbø2020-08-311-10/+0
| | | | | | Change-Id: Ibadce68775858c524b998aacad310905ba2c2e8e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* High-DPI: Remove usage of Qt::AA_EnableHighDpiScalingTor Arne Vestbø2020-08-2815-44/+1
| | | | | | | | This attribute is now on by default. Change-Id: I7c9d2e3445d204d3450758673048d514bc9c850c Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Replace QAbstractItemView::viewOptions with initViewItemOptionVolker Hilsheimer2020-08-261-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | viewOptions returned a QStyleOptionViewItem object. Such a method can never support newer versions of the option structure. Most styleable QWidget classes provide a virtual method initStyleOption that initializes the option object passed in as a pointer, e.g QFrame, QAbstractSpinBox, or QComboBox. Follow that API convention, but name it initViewItemOption, as the QStyleOptionViewItem struct contains information about the item as well as the widget itelf. This is a source incompatible change that will go unnoticed unless existing subclasses mark their overrides as 'override', or call the removed QAbstractItemView::viewOption virtual function. [ChangeLog][QtWidgets][QAbstractItemView] The virtual viewOptions method that previously returned a QStyleOptionViewItem object has been renamed to initViewItemOption, and initializes a QStyleOptionViewItem object that's passed in through a pointer. Change-Id: Ie058702aed42d77274fa3c4abb43ba302e57e348 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* macOS: rename 'macintosh' style to 'macos'Richard Moe Gustavsen2020-08-261-2/+2
| | | | | | | | | | | | | | Change the name/key of the style to 'macos'. Besides the name 'macintosh' being archaic, we also need this change to avoid creating 'macintosh' style folders in QtQuickControls, now that we plan to use QPlatformTheme also there to resolve the style. [ChangeLog][Widgets][QStyle] The 'macintosh' style has been renamed to 'macos'. Change-Id: I14b8a8b4dbd369e7a7d16b94e4ad27e501e7e8d0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Move QStateMachine from QtCore to QtScxmlKarsten Heimrich2020-08-24187-14242/+1
| | | | | | Task-number: QTBUG-80316 Change-Id: I2ee74110fd55e94d86321d3b3dc5bb8297424ed4 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Deprecate the static int based API in QMetaTypeLars Knoll2020-08-241-1/+1
| | | | | | | | | | | | | And remove one of the type id to name mapping that still existed in QMetaType. QMetaTypeInterface can provide that, so there's no need to have a second copy of the data. qMetaTypeTypeInternal() can still map all the names of all builtin types to ids. That functionality is for now still required by moc and can't be removed yet. Change-Id: Ib4f8e9c71e1e7d99d52da9e44477c9a1f1805e57 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Move QStringRef and remains to Qt5CompatKarsten Heimrich2020-08-206-12/+12
| | | | | | | | | Export some private functions from QUtf8 to resolve undefined symbols in Qt5Compat after moving QStringRef. Task-number: QTBUG-84437 Change-Id: I9046dcb14ed520d8868a511d79da6e721e26f72b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port the QXmlStream API from QStringRef to QStringViewKarsten Heimrich2020-08-191-4/+4
| | | | | | | | | | | | | | This gives some source incompatibilities, most of them can be handled by using auto instead of QStringRef explicitly. [ChangeLog][Important API changes] QXmlStream now uses QStringView insteead of QStringRef in it's API. Using auto forvariables returning a QStringRef in Qt 5 should lead to code that can be used against both Qt versions. Fixes: QTBUG-84317 Change-Id: I6df3a9507276f5d16d044a6bdbe0e4810cf99440 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Disentangle QIODevice dependenciesLars Knoll2020-08-151-2/+2
| | | | | | | | | | | | | | | | | Move the QIODevice::OpenMode enum into a base class, so that we can remove the full QIODevice (and thus QObject) dependency from qdatastream.h and qtextstream.h. This is required so that we can include QDataStream in qmetatype.h without getting circular dependencies. As a nice side effect, QDataStream and QTextStream can now inherit QIODeviceBase and provide the OpenMode enum directly in their class scope. Change-Id: Ifa68b7b1d8d95687ed032f6c9206f92e63bfacdf Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Long Live QMap as a refcounted std::map!Giuseppe D'Angelo2020-08-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... and QMultiMap as std::multimap. Just use the implementation from the STL; we can't really claim that our code is much better than STL's, or does things any differently (de facto they're both red-black trees). Decouple QMultiMap from QMap, by making it NOT inherit from QMap any longer. This completes the deprecation started in 5.15: QMap now does not store duplicated keys any more. Something to establish is where to put the QExplictlySharedDataPointer replcement that is in there as an ad-hoc solution. There's a number of patches in-flight by Marc that try to introduce the same (or very similar) functionality. Miscellanea changes to the Q(Multi)Map code itself: * consistently use size_type instead of int; * pass iterators by value; * drop QT_STRICT_ITERATORS; * iterators implictly convert to const_iterators, and APIs take const_iterators; * iterators are just bidirectional and not random access; * added noexcept where it makes sense; * "inline" dropped (churn); * qMapLessThanKey dropped (undocumented, 0 hits in Qt, 1 hit in KDE); * operator== on Q(Multi)Map requires operator== on the key type (we're checking for equality, not equivalence!). Very few breakages occur in qtbase. [ChangeLog][Potentially Source-Incompatible Changes] QMap does not support multiple equivalent keys any more. Any related functionality has been removed from QMap, following the deprecation that happened in Qt 5.15. Use QMultiMap for this use case. [ChangeLog][Potentially Source-Incompatible Changes] QMap and QMultiMap iterators random-access API have been removed. Note that the iterators have always been just bidirectional; moving an iterator by N positions can still be achieved using std::next or std::advance, at the same cost as before (O(N)). [ChangeLog][Potentially Source-Incompatible Changes] QMultiMap does not inherit from QMap any more. Amongst other things, this means that iterators on a QMultiMap now belong to the QMultiMap class (and not to the QMap class); new Java iterators have been added. Change-Id: I5a0fe9b020f92c21b37065a1defff783b5d2b7a9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Polish the settingseditor exampleFriedemann Kleint2020-07-104-107/+227
| | | | | | | | | | | | | | | | | | | | | | | The example is meant to show an item delegate with a line edit with QRegularExpression-based validation depending on type. Unfortunately, this does not work since QSettings mostly return QString types. Fix it to a partially working state by - Making the expressions match from beginning to end which was overlooked in the QRegExp->QRegularExpression change. - Use QCheckBox, QSpinBox for bool/int since it is silly to have a user edit a bool value by typing 'true'/'false'. - Move the expressions out to a separate struct to be able to do some guessing of the type when reading the QSettings, implement for bool and int. - Use a fancy Unicode checkmark for displaying bools. - Fix the garbled display of QByteArray with binary data by displaying them with hex characters and setting them read-only. Change-Id: Iba22dfafc3b813b3fd3d2915ef5210d661049382 Reviewed-by: Paul Wicking <paul.wicking@qt.io>