Backround-color for a styledpannel | sunken QLabel



  • I would like to set a particular color to the sunken part of the design, that is to say a color following the inside part of the box.

    If I
    @ whateverqlabel->setStyleSheet("QLabel { background-color : red; color : blue; }");
    whateverqlabel->setFrameStyle(QFrame::StyledPanel|QFrame::Sunken);@
    Then I obtain the whole box drawn onto an evil bigger background-colored rectangle.


  • Moderators

    I'm not sure I understood correctly. You want to style the frame itself?
    If so, you can do a sunken frame entirely with stylesheet like that:
    @
    border-top: 2px solid qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1,
    stop:0 rgba(192, 192, 192, 255), stop:1 rgba(64, 64, 64, 255));
    border-left: 2px solid qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0,
    stop:0 rgba(192, 192, 192, 255), stop:1 rgba(64, 64, 64, 255));
    border-right: 2px solid qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0,
    stop:0 rgba(192, 192, 192, 255), stop:1 rgba(255, 255, 255, 255));
    border-bottom: 2px solid qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1,
    stop:0 rgba(192, 192, 192, 255), stop:1 rgba(255, 255, 255, 255));
    @
    Adjust the colors to your needs of course.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.