Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to have a rounded background in qml TextEdit
Forum Updated to NodeBB v4.3 + New Features

How to have a rounded background in qml TextEdit

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    isudfv
    wrote on 1 Sept 2023, 03:19 last edited by
    #1

    I'm trying to have a rounded background in qml TextEdit. To something like this:enter image description here

    I tried this:

    TextEdit{
        id: text
        textFormat: TextEdit.RichText
        text: "<span style=\"color:blue;font-weight:bold;background-color:grey;border-radius:20px\">blue</span>"
    }
    

    but the border-radius attibute doesn't work. What should I do?

    S 1 Reply Last reply 1 Sept 2023, 05:26
    0
    • I isudfv
      1 Sept 2023, 03:19

      I'm trying to have a rounded background in qml TextEdit. To something like this:enter image description here

      I tried this:

      TextEdit{
          id: text
          textFormat: TextEdit.RichText
          text: "<span style=\"color:blue;font-weight:bold;background-color:grey;border-radius:20px\">blue</span>"
      }
      

      but the border-radius attibute doesn't work. What should I do?

      S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 1 Sept 2023, 05:26 last edited by
      #2

      The easiest way will be to add a Rectangle element:

      Rectangle {
        radius: 20
        width: 100
        height: 40
      
        TextEdit {
          id: text
          text: "blue"
          color: "#0000ff"
        }
      }
      

      (Z(:^

      I 1 Reply Last reply 1 Sept 2023, 07:32
      2
      • S sierdzio
        1 Sept 2023, 05:26

        The easiest way will be to add a Rectangle element:

        Rectangle {
          radius: 20
          width: 100
          height: 40
        
          TextEdit {
            id: text
            text: "blue"
            color: "#0000ff"
          }
        }
        
        I Offline
        I Offline
        isudfv
        wrote on 1 Sept 2023, 07:32 last edited by
        #3

        @sierdzio sorry I can't use this method because I'm dealing with a "highlighting" problem. Like this:cc56fafd-bf2d-486f-8118-7b4bc49b43f1-image.png
        the highlighted content is selected by user. and there're a lot of different color schemes for words to be hovered, selected, deleted and so on.

        S 1 Reply Last reply 1 Sept 2023, 07:42
        0
        • I isudfv
          1 Sept 2023, 07:32

          @sierdzio sorry I can't use this method because I'm dealing with a "highlighting" problem. Like this:cc56fafd-bf2d-486f-8118-7b4bc49b43f1-image.png
          the highlighted content is selected by user. and there're a lot of different color schemes for words to be hovered, selected, deleted and so on.

          S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 1 Sept 2023, 07:42 last edited by
          #4

          @isudfv Ah I see. Then you should do this with QTextDocument. It does support full formatting, pictures, selection etc. while maintaining very good performance.

          (Z(:^

          I 1 Reply Last reply 1 Sept 2023, 08:29
          0
          • S sierdzio
            1 Sept 2023, 07:42

            @isudfv Ah I see. Then you should do this with QTextDocument. It does support full formatting, pictures, selection etc. while maintaining very good performance.

            I Offline
            I Offline
            isudfv
            wrote on 1 Sept 2023, 08:29 last edited by
            #5

            @sierdzioThe QQuickTextDocument class provides access to the QTextDocument of QQuickTextEdit. If I understand it correctly, TextEdit in qml is implemented with QTextDocument?

            also I found this in Qt forum, so the border attibute in style is supported in qml rich text right? But I can't work it out

            1 Reply Last reply
            0

            5/5

            1 Sept 2023, 08:29

            • Login

            • Login or register to search.
            5 out of 5
            • First post
              5/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved