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

TextArea rich text css margin and padding not working.



  • import QtQuick 2.0
    import QtQuick.Controls 2.12
    
    Rectangle {
        width: 500
        height: 500
        TextArea {
            anchors.fill:parent
            color:"#FFFFFF"
            readOnly: true
            textFormat: Text.RichText
            wrapMode: Text.Wrap
            text:"<p style='background:#181818;color:white;padding:20px;margin:10px;'>HELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLDHELLO WORLD</p>"
       }
    }
    


  • Only a subset is supported:
    https://doc.qt.io/qt-5/richtext-html-subset.html
    It can be frustrating and the subset is quite limiting. If you need something like a browser using WebEngine might be better.



  • @fcarney Thanks. But webegine is too big, if I modify the rich text css rendering of TextArea of qt, is it troublesome?



  • @senmx said in TextArea rich text css margin and padding not working.:

    if I modify the rich text css rendering of TextArea of qt, is it troublesome?

    How do you propose to do that?



  • @JonB Change the qt source code?! Depends on how troublesome it is.


Log in to reply