Style sheet for rounded corners on QLineEdit?

I use Qt's style sheets to create a custom QLineEdit that has a light blue border around it when it has focus. Here is the stylesheet:

    this->setStyleSheet(" QLineEdit { "
                        " border-radius: 4px; "
                        " color:rgb(0, 0, 0); "
                        " background-color: rgb(255, 255, 255); } "

                        " QLineEdit:focus { "
                        " border-style:outset; "
                        " border-width:4px; "
                        " border-radius: 4px; "
                        " border-color: rgb(41, 237, 215); "
                        " color:rgb(0, 0, 0); "
                        " background-color: rgb(150, 150, 150); } "
                   );

And here is the result:

enter image description here

This looks pretty good, but is there a way around the corners of the QLineEdit content area? The light gray area in the image above?

In particular, could this be with Qt style sheets?

+4
source share
2 answers

border-radiusmust be greater than border-widthat least 4-5 px. Try the following:

this->setStyleSheet(" QLineEdit { "
                        " border-radius: 8px; "
                        " color:rgb(0, 0, 0); "
                        " background-color: rgb(255, 255, 255); } "

                        " QLineEdit:focus { "
                        " border:4px outset; "
                        " border-radius: 8px; "
                        " border-color: rgb(41, 237, 215); "
                        " color:rgb(0, 0, 0); "
                        " background-color: rgb(150, 150, 150); } "
                   );

It looks like:

enter image description here

+2
source

border-radius , , QLineEdit. , QLineEdit 20 10 , . , , .

0

Source: https://habr.com/ru/post/1536872/


All Articles