Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to get line with that style?



  • Hi,

    I would like to create line, which has style like this:

    line.png

    So 2 colors: white and gray and special effect ( left side is more transparent than right side ).


  • Moderators

    You could also use a widget with a stylesheet. Assuming the widget is 20px high something like this:

    widget->setStyleSheet(
       "border-top: 10px solid qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 rgba(200, 200, 200, 0), stop:1 rgba(200, 200, 200, 255));"
       "border-bottom: 10px solid qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 rgba(255, 255, 255, 0), stop:1 rgba(255, 255, 255, 255));"
    );
    

  • Lifetime Qt Champion

    Hi
    You might be able to get that effect using QGradiant and QPainter but
    you could also just use a PNG with it predrawn and paint that.

    Do you need it in many sizes ?


  • Moderators

    You could also use a widget with a stylesheet. Assuming the widget is 20px high something like this:

    widget->setStyleSheet(
       "border-top: 10px solid qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 rgba(200, 200, 200, 0), stop:1 rgba(200, 200, 200, 255));"
       "border-bottom: 10px solid qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 rgba(255, 255, 255, 0), stop:1 rgba(255, 255, 255, 255));"
    );
    

Log in to reply