Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to realized the style of Edit Box like this picture shows.



  • 0_1525743610451_2018-05-08 09_39_47-Marketch(https___github.com_tudou527) - Internet Explorer.png

    How to realized this style of EditBox.
    Special txt can be auto treated as an block, and can be move or delete just like one charactor.
    Thanks


  • Lifetime Qt Champion

    Hi
    so it must contain "boxes" like SOH ?
    also, there will also be editable text ? or just
    a collection of boxes ?
    You could use a list in iconview mode to show it like that if all boxes is same size.

    If you need it with floating/editable text also, i think you need to specify a bit more the needed
    operations on the boxes and the texts then. before i can suggest how you can make it.

    There is TextEdit with images but not sure what boxes can do. if it needs to popup menu and be closable
    as image indicates, it might not work super.



  • @mrjj said in How to realized the style of Edit Box like this picture shows.:

    Hi
    so it must contain "boxes" like SOH ?
    also, there will also be editable text ? or just
    a collection of boxes ?
    You could use a list in iconview mode to show it like that if all boxes is same size.

    If you need it with floating/editable text also, i think you need to specify a bit more the needed
    operations on the boxes and the texts then. before i can suggest how you can make it.

    There is TextEdit with images but not sure what boxes can do. if it needs to popup menu and be closable
    as image indicates, it might not work super.

    Thanks for reply.

    1. There will be many kinds of "boxes" not only SOH, but also have NUL ACK CR LF etc. both of them are invisible characters in ASCII table.
    2. One "box" is treated as one item in the edit box.
    3. "Box" can be delete by click x
    4. "Box" can be moved in edit box as an entirety.
    5. There will be also editable text , just like:
      [SOH]hello[CR]

  • Lifetime Qt Champion

    @brucezcg
    One option is create a custom object for TextEdit
    http://doc.qt.io/qt-5/qtsvg-richtext-textobject-example.html
    But im not 100% sure you can easy get click events for it.

    Option 2 would be a custom Widget for "Box" and QLabel with
    TextInteractionFlags set to Qt::TextEditable.
    And then something like a box layout to hold them.
    But if you need to be able to drag them around also, it might be a bit clumsy
    removing and inserting into layout.

    do you need rich text formatting like bold etc ?



  • @mrjj said in How to realized the style of Edit Box like this picture shows.:

    @brucezcg
    One option is create a custom object for TextEdit
    http://doc.qt.io/qt-5/qtsvg-richtext-textobject-example.html
    But im not 100% sure you can easy get click events for it.

    Option 2 would be a custom Widget for "Box" and QLabel with
    TextInteractionFlags set to Qt::TextEditable.
    And then something like a box layout to hold them.
    But if you need to be able to drag them around also, it might be a bit clumsy
    removing and inserting into layout.

    do you need rich text formatting like bold etc ?

    Thanks, I don't need need to format the text.
    As you say, this is big effort to realize what I want


  • Lifetime Qt Champion

    @brucezcg
    Yes, its not trivial to create due to mixed box feature and editable text.
    Especially the drag around part.
    I think the textobject way will work the best.
    It can even drag the object but it seems to vanish bt i assume its fixable :)


Log in to reply