Hello,
 
having used QtQuick professionally for serveral years now, I have some 
suggestions regarding the text handling in Qt Quick.
One major point of interest for me is rich text handling. A large number of 
modern (mostly HTML/Electron-based) applications nowadays feature smart text 
input fields which are able to automatically highlight or link certain parts of 
the text and show buttons, tags, emojis or similar controls inlined in the 
text. These kinds of controls get more and more important in UI development.
 
As of yet, QtQuick lacks such a feature. Anything going beyond very basic 
hyperlink/image support requires developers to resort to the RichText mode 
which however only allows you to use a subset of HTML rather than your own 
QtQuick Controls which has a bad performance impact and requires more 
development effort.
 
I would like propose a new layout control in QML for positioning an arbitrary 
composition of text and other QtQuick elements. It should support user 
selection and user editing (similar to contenteditable=true in HTML) and let 
the QML elements inside the text react to them being selected.
The syntax I have in mind could look like this:
 
TextLayout {
    alignment: Qt.AlignLeft
    editable: true
    selectionAllowed: true
 
    TextSpan {
        text: "Lorem ipsum dolor sit amet"
    }
    Button {
        label: "Click me"
        TextLayout.alignment: TextLayout.Center
        background: TextLayout.isSelected ? "blue" : "white"
    }
    TextSpan {
        text: "Text after the button"        
        TextLayout.allowSelection: false
    }
    TextSpan {
        lineBreakBefore: true
        color: "red"
        text: "more text"
    }
}
 
This is inspired by the TextSpan and WidgetSpan controls in Flutter:
https://api.flutter.dev/flutter/widgets/WidgetSpan-class.html
https://api.flutter.dev/flutter/painting/TextSpan-class.html
 
The second proposal I would like to make affects custom QtQuick controls 
developed in C++. As of now, it is practically impossible to implement custom 
scene graph controls (not QQuickPaintedItems) containing text without using the 
private QQuickTextNode. This node should be made public, or different APIs for 
painting text via the scene graph should be exposed.
 
Are there already plans to include such features for Qt6 in the near future?
 
Best regards,
 
Steven
_______________________________________________
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to