Hello all, I want to ask a question about QPalette and QLinearGradient.
I want to brush my sub widget with QLinerGradient. I have created ui by using QtDesigner. [image: enter image description here] <http://i.stack.imgur.com/5JzSK.png> But I can not brush this widget by using this code.(ui.colorBarWidget is normal QWidget was created by QtDesigner.) QPalette palette; QLinearGradient gradient(ui.colorBarWidget->rect().topLeft(),ui.colorBarWidget->rect().topRight()); gradient.setColorAt(0, Qt::blue); gradient.setColorAt(0.2, Qt::green); gradient.setColorAt(0.4, Qt::red); gradient.setColorAt(0.6, Qt::yellow); gradient.setColorAt(1, Qt::cyan); palette.setBrush(QPalette::Base, gradient); ui.colorBarWidget->setPalette(palette); In addition this code works in stand alone QWidget application.This is its output: [image: enter image description here] <http://i.stack.imgur.com/z5fc5.png> But I can not do same thing in my design. I can do this with styleSheet ui.colorBarWidget->setStyleSheet( "background-color: qlineargradient( x1:0 y1:0, x2:0 y2:1, stop:0 blue, stop:1 red )" ); /* works */ but why I can not do this with QPalette. Thanks in advance.
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest