使用样式定义:

    QWidget* toolbar = new QWidget(this);
    toolbar->setObjectName("main_tool");
    toolbar->setStyleSheet("#main_tool{background: qlineargradient(x1:0 , y1:0 , x2:1 , y2:0,"
                           "stop:0    rgba(0,255,0, 0.2),"
                           "stop:0.2  rgba(0,255,0, 0.4),"
                           "stop:0.5  rgba(0,255,0, 0.5),"
                           "stop:0.8  rgba(0,255,0, 0.4),"
                           "stop:1    rgba(0,255,0, 0.2));}");

QT自定义工具条渐变背景颜色一例-LMLPHP

07-10 06:15