[Solved] What are the differences between TextField and TextInput. Also TextArea and TextEdit?



  • Both TextField and TextInput are single line text edit.
    TextInput seems to have more functions than TextField.

    Both TextArea and TextEdit support multi-lines text edit.
    And the functions are similar.

    I don't understand, why two sets of edit controls? Which one should I use?



  • TextEdit and TextInput are derived classes from ... QWidget

    I think TextArea and TextField was added with QtQuickControls.
    They are derived classes from ... QQuickItem.

    bq. Which one should I use?

    Just have a look on this page, maybe it will help you:
    http://qt-project.org/doc/qt-5/topics-ui.html#comparison

    The decision between QtQuick and QtWidgets depends on your usage.



  • Hawk: not really. I believe he refers to the controls vs the built-int Qt Quick primitives. Which one to use depends on your the case:

    TextField and TextArea are fully developed controls complete with native or custom styling that can be directly used in layouts or forms without you providing anything else. If you are coming from the widget world, this is most likely what you are looking for. They generally have a somewhat simpler API because they will implicitly adopt the behavior from the platform they are used on.

    TextInput and TextEdit are only primitives. They provide a more extensive api but require you to provide your own background, frame, size hint and default behavior. If you are building your own component set for instance in a custom car dashboard or similar this is probably what you want to use.

    I could probably add that TextField and TextEdit make use of TextInput and TextArea as part of their implementation.



  • [quote author="Hawk30100" date="1400049362"]TextEdit and TextInput are derived classes from ... QWidget

    I think TextArea and TextField was added with QtQuickControls.
    They are derived classes from ... QQuickItem.
    [/quote]
    Thanks Hawk, but Jens was right, I wasn't talking about QWidget at all :)

    [quote author="Jens" date="1400058672"]
    I could probably add that TextField and TextEdit make use of TextInput and TextArea as part of their implementation.[/quote]
    Thanks Jens! Realizing that a TextField actually embeds a TextInput, and a TextArea actually embeds a TextEdit clears lots of doubt :)

    For those interested, you can see how TextField and TextArea are implemented here:
    C:\Qt\Qt5.2.1\5.2.1\Src\qtquickcontrols\src\controls\TextField.qml
    C:\Qt\Qt5.2.1\5.2.1\Src\qtquickcontrols\src\controls\TextArea.qml


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.