aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols/texteditor
Commit message (Collapse)AuthorAgeFilesLines
* Doc: Add alternate text for Qt Quick and Qt Quick Controls imagesJerome Pasion5 days1-0/+2
| | | | | | | | | | 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-135120 Change-Id: I975c3de11f893882fb9a27218079f244bd38a622 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* texteditor: Change the HTML to use unordered lists for linksOliver Eftevaag2025-09-031-11/+12
| | | | | | | | | | The text layout in this example has annoyed me for a while. I liked it better when each link was a list item, which used to be the case before a96871eac888e0c01b29d092bafa80755f1fb47a. Pick-to: 6.10 Change-Id: I68a6570dbc6c30e63b9d5b8b8079c9a58ab4e728 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* TextEditor example: allow setting multiple font attributesShawn Rutledge2025-04-291-4/+4
| | | | | | | | | | | | | | | | | | | | When a user activates the boldAction for example, the code was replacing QTextCharFormat's font with a default-constructed font that has the bold attribute set, which meant that it could not be bold, italic, underlined struck out, and with a custom size and color at the same time. On the other hand, when we do it the current way: textArea.cursorSelection.font.bold = checked we call QQuickTextSelection::font(), QFont::setBold(), and then QQuickTextSelection::setFont(). (QFont is a QML value type, so it's the only way.) Perhaps at some point, something was going wrong with that, but it seems to work now. Amends 045f9ce192d841f3cc36d514b5f238b46488b41e Fixes: QTBUG-136250 Pick-to: 6.8 6.9 Change-Id: I268e5814e7aa52aeb5aaec2d1a8fbfbc0d670236 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* TextEditor example: Add font and color dialog actions to Format menuShawn Rutledge2025-04-281-0/+6
| | | | | | | Task-number: QTBUG-136251 Pick-to: 6.8 6.9 Change-Id: I64d7a406d4acff5395cfc18c201888c17a44e10f Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Improve QML in Controls TextEditor exampleShawn Rutledge2025-04-281-11/+2
| | | | | | | Pick-to: 6.8 6.9 Task-number: QTBUG-119988 Change-Id: Iffc7df85f25024301efef591eb3fbfb1cfbe2f17 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* TextEditor example: add actions to built-in context menu, remove custom menuShawn Rutledge2025-04-082-55/+35
| | | | | | | | | | | Since 3b598b6f7509f57e198e7de1f04e4333555e7227 TextArea comes with a built-in context menu. Here we demonstrate how to add extra menu items to the end. Pick-to: 6.9 Task-number: QTBUG-35598 Task-number: QTBUG-134903 Change-Id: I1e3d8c044939521aaa076486630e3b879130dfd1 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Examples: use qt_standard_project_setup in more placesFabian Kosmale2024-07-031-2/+2
| | | | | | | | | | | | And remove the redundant AUTOMOC lines. This also avoids a few policy related warnings. Task-number: QTBUG-126201 Pick-to: 6.8 Change-Id: Idaa58d7fbc0236aa2091ead43d5a0e6f396647e1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Doc: Fix qsTr() linkAndreas Eliasson2024-07-011-3/+3
| | | | | | | | | Fixes qdoc warning: qtquickcontrols-texteditor.qdoc:128: Can't link to 'qsTr' Pick-to: 6.8 6.7 Change-Id: Ib2543779cc97052fd754b417468cb315313503a9 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* CMake: Add deployment API to our examplesAlexandru Croitor2024-03-271-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Projects were modified using the tool at: https://git.qt.io/alcroito/cmake_refactor A few examples had to be adapted manually, mostly those that build additional qml modules / plugins. The INSTALL_EXAMPLESDIR and INSTALL_EXAMPLEDIR assignments were removed, these are not needed anymore because example directory selection is handled by the qt_internal_add_example calls. The install(TARGETS) calls were modified according to our documentation snippets for qt_generate_deploy_qml_app_script. A qt_generate_deploy_qml_app_script call was added for each executable target. Note that the deployment step will be skipped in the CI for now, because: - we enable QT_DEPLOY_MINIMAL_EXAMPLES in the CI instructions and thus set QT_INTERNAL_SKIP_DEPLOYMENT to true - standalone examples feature is not yet enabled in the CI, which means we continue to build examples in-tree, and deployment is disabled for in-tree prefix builds. A small list of examples to deploy in the CI will be chosen in the future, to ensure deployment coverage, without slowing down overall CI times due to all the *deployqt invocations. Even if deployment is disabled in the CI, the install(TARGETS) calls for each example will still run, installing into an 'installed_examples' directory, which will not be archived by the CI. The QtBundleQmlModuleForMacOS and bundle_shared code was removed, because we can now depend on the MACOS_BUNDLE_POST_BUILD option of the deployment api, to ensure macOS bundle examples run properly in the build dir. This works even in prefix in-tree builds, when installation deployment is disabled. Finally, for all examples that build additional qml module libraries or plugins, the libraries / plugins must be installed into the bin dir of each project, along with a qmldir file. This is to support running the installed project for platforms that don't have deployment api yet, like boot2qt / yocto. If we want to have super clean install / deployment rules in the future, we won't be able to avoid adding ugly per-platform conditions. The current status quo is deemed an improvement over what we had before. Pick-to: 6.7 Task-number: QTBUG-101340 Task-number: QTBUG-102056 Task-number: QTBUG-102057 Change-Id: I843d934668c25dbcd1abca52495b393579633fc5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Correct license for examples filesLucie Gérard2024-03-211-1/+1
| | | | | | | | | | | | | Example takes precedent over build system file type. According to QUIP-18 [1], all examples file should be LicenseRef-Qt-Commercial OR BSD-3-Clause [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 6.7.0 Task-number: QTBUG-121787 Change-Id: Ie8c2539e7659f53a1fd6b48f99ee883ee9aeb0a7 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Adjust Controls Text Editor example and docs furtherShawn Rutledge2024-03-185-36/+16
| | | | | | | | | | | | | | | | - text formatting includes alignment, not just font properties - update links in example.md - update texteditor.html: don't mention Qt Labs Platform, but link to some recent new stuff - if ToolButton.action is bound, enabled is redundant (the Action already has it) - don't include QApplication Amends 6217408799c43869b8a7c1fcbff882d42ae71171 and 21b3c4741ef07044952d1cae18ed9665cafe00c3 Change-Id: Ie4565829f02d8ee1541ba4af9d64bd044739179f Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* doc: Update Controls Text Editor example docsShawn Rutledge2024-03-122-36/+129
| | | | | | | | We also move ScrollBar to make explanation easier. Pick-to: 6.7 6.7.0 Change-Id: If65de335f840382b5e236d8a04db382b0b7aee6a Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* TextEditor example: use Actions in a DRY way; TapHandlerShawn Rutledge2024-03-121-56/+40
| | | | | | | | | | | | | | | | | I'm not sure why the example was written with so much repetition, but there must have been limitations back then. It's better to have Action as the encapsulation for an operation, and simply bind it to all the places where it's used (menubar, toolbar and context menu). It would be even better if an Action could be added directly to a Menu or ToolBar, but so far there's not a declarative way to do that (only by using addAction(), which is only in Menu, not ToolBar). We now use TapHandler instead of MouseArea to open the context menu. It works fine either way, but at least we don't need anchors.fill. Pick-to: 6.7 6.7.0 Change-Id: I74900ec49b57b616ffacddcf81c5aea12d4fefe6 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* doc: Update TextEdit.textFormat, text and TextDocument.sourceShawn Rutledge2024-03-061-1/+1
| | | | | | | | | Update docs after b46d6a75ac16089de1a29c773e7594a82ffea13e, fdbacf2d5c0a04925bcb3aecd7bf47da5fb69227 etc. Pick-to: 6.7 Change-Id: Ieb49d6876f0a86031fb0ffe970f695e5acbe4c43 Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Update manual tests and examples for change in default size policySanthosh Kumar2024-02-211-0/+2
| | | | | | | | | | | The size policy of item updated as part of task QTBUG-117597. This patch update existing examples and manual tests that depends on quick layout to embrace size policy change. Task-number: QTBUG-117597 Pick-to: 6.7 Change-Id: I68469a3bba3c4d3e5ed4b6eae0fd765b5206efc0 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Text editor example: fix up the touch-specific UIShawn Rutledge2024-02-151-27/+81
| | | | | | | | | | | | | | | | | | | | | Catch up with recent changes in the default texteditor.qml file: - TextDocument.status is new; the error signal is gone. Update as in bec8df96b7615c6ce419867254027773ea7fd6b1 and 1e6cb2462ee87476a5eab7c71735c001a46c7b55 - 3bae41faace0d52a317cd015598ff1d0d8b823b7 changed the mapping of the "OK" checkmark in fontello.ttf - use Actions to show and change cursorSelection styling, as in 045f9ce192d841f3cc36d514b5f238b46488b41e - set a default window size; it doesn't matter on a mobile device that runs everything fullscreen, but it's easier to test on desktop with the -touch flag Fixes: QTBUG-121840 Task-number: QTBUG-121946 Pick-to: 6.7 Change-Id: If678b92efe4e1824022fa0ee9106c0c3b0b9f194 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Use lookup table to show TextDocument status in texteditor exampleShawn Rutledge2024-02-121-17/+11
| | | | | | | | | | | | Computed properties make it possible to use scoped enum values as object property names. Amends bec8df96b7615c6ce419867254027773ea7fd6b1 Also remove semicolons for consistency. Pick-to: 6.7 Task-number: QTBUG-121946 Change-Id: I1ee354722d9f0e065637731d1b535389a9cb0032 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* texteditor example: use TextDocument status rather than error signalShawn Rutledge2024-02-051-3/+19
| | | | | | | | | Amends 5647b6900b2ecc291022143176b545b933eca3a8 in which the error signal was removed and replaced with a status property. Pick-to: 6.7 Change-Id: I433987fe4c480c910c98c8fd3714c2e426e49c0f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Doc: Create separate Graphics and Multimedia example categoriesJaishree Vyas2024-01-171-1/+1
| | | | | | | Fixes: QTBUG-117884 Pick-to: 6.6 6.7 Change-Id: Ib0bb6217c29795fe50efdf827aa9902bbd572032 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Controls TextEditor example: remove Qt.labs and the widget dependencyShawn Rutledge2023-12-153-36/+28
| | | | | | | | | | This depends on the plan to have the Controls MenuBar and context Menu "go native" on platforms that support it. Task-number: QTBUG-119988 Task-number: QTBUG-106782 Change-Id: Ib8354b44bde385717431534d0260182715d66f16 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Get rid of DocumentHandler in the Text Editor exampleShawn Rutledge2023-12-098-555/+22
| | | | | | | | ...and fix a couple of minor issues that remained. Fixes: QTBUG-81022 Change-Id: I5fc1547fb09caef5a9e24d95c2ca7b8d78ee104a Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Add TextSelection (Tech Preview)Shawn Rutledge2023-12-081-50/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the Controls text editor example, DocumentHandler always sounded like a hack, just by its name. We don't expect to be able to handle multiple selections anytime soon; but if we realistically expect to have multi-seat support in Qt some day, then probably the multi-user experience should include support for multiple text cursors and selections. So we shouldn't paint ourselves into a corner. QQuickTextControl works with only one QTextCursor most of the time (but it's private, thus modifiable); and TextEdit has properties like selectionStart, selectionEnd, selectedText, etc. which seem to assume that there is only one selection. So probably if we needed to support multiple selections, we could add Q_PROPERTY(QQmlListProperty<QQuickTextSelection> selections ...), document that those legacy properties just work with the first selection, and/or deprecate them. So with that in mind, let's get started with a QQuickTextSelection object. We add TextEdit.cursorSelection which holds the single selection near the text cursor. It provides API needed for tracking and manipulating often-used properties of selected rich text (such as QTextCharFormat properties) so that DocumentHandler can be removed. The example now uses TextArea.cursorSelection to manipulate the selected text's format. It's not possible to be fully declarative with this API though; we need to call setFont (by assigning a font), but QFont is a value type, and is not as mergeable as QTextCharFormat is, for example. If we used a binding rather than Action.onTriggered, it would trigger reading the font for an entire span of selected text (which may have had multiple fonts), setting one attribute (like bold), then applying the font to the whole span. What we do now is almost like that; but instead of reading the font first, we start with a default-constructed QFont, set one attribute, and call QTextCursor::mergeCharFormat(), in the hope that it can merge only the features of QFont that have actually been set. Unfortunately this is not quite true either: if you toggle the bold button, it might change the font size too, and so on; so maybe we really need QTextCharFormat in QML (as a value type, presumably) to implement those feature-toggling toolbar buttons correctly. This API is in tech preview, because of such issues as described above; because we're just scratching the surface of what might be possible; because we should perhaps compare popular JavaScript text-editing APIs that might be found elsewhere, in the meantime get feedback from users during the tech preview phase, and keep iterating. [ChangeLog][QtQuick][TextEdit] TextEdit.cursorSelection is a TextSelection object, which provides properties to inspect and modify the formatting of the single selection that is currently supported. This API is in Tech Preview. [ChangeLog][Controls][TextArea] TextArea.cursorSelection is a TextSelection object, which provides properties to inspect and modify the formatting of the single selection that is currently supported. This API is in Tech Preview. Task-number: QTBUG-36521 Task-number: QTBUG-38830 Task-number: QTBUG-81022 Change-Id: Icea99f633694aa712d0b4730b77369077288540f Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Add load/save functionality to QQuickTextDocument (Tech Preview)Shawn Rutledge2023-12-081-9/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since QTBUG-92155 is not done, we need an easy way to load and save text into and out of a QTextDocument in QML. This patch follows the pattern from Image and other types: add a `source` property, a URL from which the file is to be loaded. When it comes to saving, the pattern is not set: so far the only file writing that has been available from QML is ItemGrabResult.saveToFile(). Since we need to save in specific formats, it makes sense to continue that pattern: the text document knows how to do its own serialization, so this is not suitable for generic data file I/O, even if we did have a QML API for that. We add invokable functions save() and saveAs() for the usual use cases in word processors and such. The URL extension determines the file format. Setting QQuickTextDocument's source is not allowed if the document has unsaved changes. The user (app author) needs to call save() or override modified to false first. [ChangeLog][QtQuick][TextEdit] TextEdit.textDocument now has a source property for loading files; save() and saveAs() functions for writing; a modified property which tracks QTextDocument::modified; and an error signal in case any of these operations fail. Setting the source property is allowed only if the document is in unmodified state. This API is in Tech Preview. [ChangeLog][Controls][TextArea] TextArea.textDocument now has a source property for loading files; save() and saveAs() functions for writing; a modified property which tracks QTextDocument::modified; and an error signal in case any of these operations fail. Setting the source property is allowed only if the document is in unmodified state. This API is in Tech Preview. Change-Id: I687318523c7a520e02244e47224d067da55318b5 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* TextEdit example: Add more FontAwesome icons to fontello.ttfShawn Rutledge2023-12-081-0/+0
| | | | | | | We'll soon be adding functionality to this example. Change-Id: If084ce88b3008bfccc96e9ae059b32a99df9cfdf Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* TextEditor example: open file as textSami Shalayel2023-11-101-1/+1
| | | | | | | | | | | | The texteditor is made to open text, and in this case it makes sense to pass the Text flag to the QFile::open call in the example code. Pick-to: 6.5 6.6 Task-number: QTBUG-118636 Change-Id: I936610945aa6e2f67b29ce6f5c559a2b942fc718 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Doc: Add \examplecategory for Qt Quick ControlsVenugopal Shivashankar2023-07-211-0/+1
| | | | | | | | | | Also, changed one of the example pages to a tutorial page. Task-number: QTBUG-115297 Pick-to: 6.5 6.6 Change-Id: Ife1b740523039b9287008a1c5243edfc4c1349d1 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Examples: Use versioned CMake targets for Qt modulesKai Köhne2023-05-021-6/+6
| | | | | | | | | | | | Use e.g. Qt6::Core instead of Qt::Core. This is better matching the find_package(Qt6 ...) call, and also avoids issues that the versionless targets have. Pick-to: 6.5 Task-number: QTBUG-113277 Change-Id: Ib80f885e9f73fb9ad54b9e9b22cae2318877dc07 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Gallery/Text editor: Update example logosFriedemann Kleint2023-03-271-0/+0
| | | | | | | Pick-to: 6.5 Change-Id: I552edf074958be3af8c72042e65c6586308f434f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* CMake: Allow omitting the version of QML modulesUlf Hermann2023-01-271-1/+0
| | | | | | | | | | | | | | | | | Also, drop all the VERSION 1.0 lines from the examples and tests. 1.0 is actually a bad default version since it's before all the Qt versions. [ChangeLog][QML] You can now omit the VERSION argument to qt_add_qml_module(). This will automatically generate the highest possible version. Pick-to: 6.5 Task-number: QTBUG-99146 Change-Id: Ic10ec69b87c224e0e94e1785f65653815d4c778c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* TextEditor example: Avoid deprecation warningUlf Hermann2023-01-111-1/+1
| | | | | | | | | | What we want there is intercept the URL through the QML engine. No need to dig out the specific QQmlFileSelector for that. Pick-to: 6.5 Fixes: QTBUG-102777 Change-Id: I5ca59316a2434013f91afdf92d3e397ea2711128 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Doc: remove "2" from Qt Quick Controls filesMitch Curtis2022-12-015-5/+5
| | | | | | | | | | | | | Work on this was already started for the documentation in 1abdfe5d5a052f2298b7bf657513dfa7e0c66a56. The CMake target (docs_QuickControls2) probably can't be renamed until we rename the library, which won't happen until Qt 7. Task-number: QTBUG-95413 Change-Id: Ied20805a91286436606577c3de39671a447f27dd Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Remove "2" from Qt Quick Controls directoriesMitch Curtis2022-12-0119-0/+1646
Qt Quick Controls 2 was named that way because it was a follow-up to Qt Quick Controls 1.x. Now that Qt Quick Controls 1 is no longer supported, we don't need to have "2" in the name. Work on this was already started for the documentation in 1abdfe5d5a052f2298b7bf657513dfa7e0c66a56. By doing this renaming a few weeks before feature freeze, it won't affect the release but still results in as little time possible spent manually fixing conflicts in cherry-picks from non-LTS releases as a result of the renaming. This patch does the following: - Renames directories. - Adapts CMakeLists.txt and other files to account for the new paths. A follow-up patch will handle documentation. It does not touch library names or other user-facing stuff, as that will have to be done in Qt 7. Task-number: QTBUG-95413 Change-Id: I170d8db19033ee71e495ff0c5c1a517a41ed7634 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>