Important: Please read the Qt Code of Conduct -

[SOLVED]Help with retaining only two sides of QLabel border

  • Hey everybody!

            I just had a quick question. Is it possible for a _QLabel_ to have borders only on two sides (right and left or bottom and top)? I'm setting the stylesheet on my _QLabel_ as

    lbl->setStyleSheet("border: 1px solid black");

    Is it possible to specify on what sides do I want the border?
    Thank you.

  • From "this": it does not seem possible. But If you carefully observe, you can set a border image to emulate what you want by providing a darktone on one side and a transitioned lighter tone on the other side to match the widget (Qlabel) color.

  • Bummer! I was quite hopeful there would be a way to achieve this in Qt. Thanks for the idea of camouflaging the rest of the borders with the background but I'm afraid it wouldn't be of much use in this project because my background image is not permanent.
    Anyway, thanks for your help prady :)

  • "Documentation": of Qt Stylesheet says that you can use border-top border-left, however I have not tested and am not sure if they work. Go to Properties and after the first "border" the next properties are about top left bottom and right borders. :)

  • OMG! You're right. It works :) I read the documentation for QLabel but didn't find anything there. stylesheets documentation didn't even cross my mind. I'm gonna bookmark it right away. There's so much to learn in that.

    Thank you SO SO MUCH b1gsnak3 :)

    P.S. - I just got more reasons to stick to coding in Qt. There's nothing Qt can't do. Love it! And super love this forum. Cheers!

  • tihi xD good luck

Log in to reply