Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextEdit doesn't display its corner with border-radius
QtWS25 Last Chance

QTextEdit doesn't display its corner with border-radius

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtexteditborder-radius
11 Posts 4 Posters 7.9k Views
  • 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.
  • T Offline
    T Offline
    Toufi
    wrote on 12 Jan 2016, 20:38 last edited by
    #1

    Hello,
    My problem is that I can't make my subclass of QTextEdit have rounded borders.
    Because when I use the stylesheet property border-radius, the corners are not displayed.

    // In my TextEdit constructor :
    setStyleSheet("border: 1px solid; border-radius:10px;");
    

    ScreenShot
    I use Windows 10 with Qt5.5.1
    I hope you will be able to help me...
    (and sorry for the bad english, I'm french ^^)

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 12 Jan 2016, 21:00 last edited by
      #2

      Hi, welcome to devnet.

      Looks like a small bug in the way stylesheets are applied. You can workaround it by explicitly setting a background color:

      setStyleSheet("border: 1px solid; border-radius:10px; background-color: palette(base); ");
      
      T G F 3 Replies Last reply 13 Jan 2016, 14:24
      4
      • C Chris Kawa
        12 Jan 2016, 21:00

        Hi, welcome to devnet.

        Looks like a small bug in the way stylesheets are applied. You can workaround it by explicitly setting a background color:

        setStyleSheet("border: 1px solid; border-radius:10px; background-color: palette(base); ");
        
        T Offline
        T Offline
        Toufi
        wrote on 13 Jan 2016, 14:24 last edited by
        #3

        @Chris-Kawa It works ! Thanks for all ^^

        1 Reply Last reply
        0
        • C Chris Kawa
          12 Jan 2016, 21:00

          Hi, welcome to devnet.

          Looks like a small bug in the way stylesheets are applied. You can workaround it by explicitly setting a background color:

          setStyleSheet("border: 1px solid; border-radius:10px; background-color: palette(base); ");
          
          G Offline
          G Offline
          Gaobo
          wrote on 27 Jul 2022, 08:25 last edited by
          #4

          @Chris-Kawa Why is it useless to set border-radius for QTextEdit without setting a background? It's confusing to me.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on 27 Jul 2022, 08:30 last edited by
            #5

            Apparently changing just border radius does not internally trigger changing a style from the native one to stylesheets. Like I said - could be a bug. Have a look at the source code of QWidget and setStyleSheet if you're interested.

            G 1 Reply Last reply 27 Jul 2022, 08:53
            0
            • C Chris Kawa
              27 Jul 2022, 08:30

              Apparently changing just border radius does not internally trigger changing a style from the native one to stylesheets. Like I said - could be a bug. Have a look at the source code of QWidget and setStyleSheet if you're interested.

              G Offline
              G Offline
              Gaobo
              wrote on 27 Jul 2022, 08:53 last edited by
              #6

              @Chris-Kawa Thanks. But why it is useful for QLabel.

              C 1 Reply Last reply 27 Jul 2022, 09:00
              0
              • G Gaobo
                27 Jul 2022, 08:53

                @Chris-Kawa Thanks. But why it is useful for QLabel.

                C Offline
                C Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on 27 Jul 2022, 09:00 last edited by
                #7

                @Gaobo Sorry, I don't understand the question. Why is it useful? It's your label. How should I know why it is useful to you?

                G 1 Reply Last reply 27 Jul 2022, 09:05
                0
                • C Chris Kawa
                  27 Jul 2022, 09:00

                  @Gaobo Sorry, I don't understand the question. Why is it useful? It's your label. How should I know why it is useful to you?

                  G Offline
                  G Offline
                  Gaobo
                  wrote on 27 Jul 2022, 09:05 last edited by
                  #8

                  @Chris-Kawa Sorry for my poor expresson. I mean, it's useful that I only set the border-radius for QLabel and not the background.

                  1 Reply Last reply
                  0
                  • C Chris Kawa
                    12 Jan 2016, 21:00

                    Hi, welcome to devnet.

                    Looks like a small bug in the way stylesheets are applied. You can workaround it by explicitly setting a background color:

                    setStyleSheet("border: 1px solid; border-radius:10px; background-color: palette(base); ");
                    
                    F Offline
                    F Offline
                    funway
                    wrote on 11 May 2023, 14:30 last edited by
                    #9

                    @Chris-Kawa
                    I found QScrollArea has the same question, but explicitly setting a background color does not work for QScrollArea.

                    QScrollArea {
                         border: 1px solid silver;
                         border-radius: 10px;
                         background-color: palette(base);
                    }
                    

                    SCR-20230511-tldk.png

                    Could you please give me some tips on this? Thanks.

                    C 1 Reply Last reply 11 May 2023, 20:27
                    0
                    • F funway
                      11 May 2023, 14:30

                      @Chris-Kawa
                      I found QScrollArea has the same question, but explicitly setting a background color does not work for QScrollArea.

                      QScrollArea {
                           border: 1px solid silver;
                           border-radius: 10px;
                           background-color: palette(base);
                      }
                      

                      SCR-20230511-tldk.png

                      Could you please give me some tips on this? Thanks.

                      C Offline
                      C Offline
                      Chris Kawa
                      Lifetime Qt Champion
                      wrote on 11 May 2023, 20:27 last edited by
                      #10

                      @funway It's a bit different issue. Setting border radius does not clip children painting to the rounded corners of the parent (I'm guessing for performance reasons).
                      Scroll area has a viewport widget and (optionally) scrollbars that stick to the edges of it, so they will always cover the parent's rounded corners.

                      The easiest I think would be to disable the scroll area's border entirely and place it in a container widget that has border with rounded corners and matching content margins set. This of course means that you would get a bit of empty space around the scroll area.

                      If that's not an option you could maybe add a transparent for input widget on top of the scroll area (or 4 small ones in the corners) and draw the rounded corners in it. That should get you what you want but is a bit more work. Note that the rounded corner would cover scrollbars, which in some styles might not look too good.

                      F 1 Reply Last reply 12 May 2023, 02:19
                      0
                      • C Chris Kawa
                        11 May 2023, 20:27

                        @funway It's a bit different issue. Setting border radius does not clip children painting to the rounded corners of the parent (I'm guessing for performance reasons).
                        Scroll area has a viewport widget and (optionally) scrollbars that stick to the edges of it, so they will always cover the parent's rounded corners.

                        The easiest I think would be to disable the scroll area's border entirely and place it in a container widget that has border with rounded corners and matching content margins set. This of course means that you would get a bit of empty space around the scroll area.

                        If that's not an option you could maybe add a transparent for input widget on top of the scroll area (or 4 small ones in the corners) and draw the rounded corners in it. That should get you what you want but is a bit more work. Note that the rounded corner would cover scrollbars, which in some styles might not look too good.

                        F Offline
                        F Offline
                        funway
                        wrote on 12 May 2023, 02:19 last edited by
                        #11

                        @Chris-Kawa Wow! Thanks for your detailed reply. I will try it. 🙏

                        1 Reply Last reply
                        0
                        • I isudfv referenced this topic on 1 Sept 2023, 08:29

                        • Login

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