zimang
2nd December 2010, 09:30
Hi, guys:
I want to draw a LinearGradient background for QCombobox item when item was focused.
I can't use CSS do it.
Now I use the code like this: but it seems like that it LinearGradiented for all items as one;
QLinearGradient linearGradient2(0, 0, 0, 100);
linearGradient2.setColorAt(0, QColor(132, 132, 132, 0));
linearGradient2.setColorAt(0.96, QColor(132, 132, 32, 255));
p.setBrush(QPalette::Highlight, QBrush(linearGradient2));
this->setPalette(p);
Thanks a lot!
Added after 15 minutes:
The Qt deal with the 1st item, 2nd .. .. as a pic. I just want to do each item like the 1st one.
1:
http://blog.chinaunix.net/photo/94700_101202172658.jpg
2:
http://blog.chinaunix.net/photo/94700_101202172709.jpg
3:
http://blog.chinaunix.net/photo/94700_101202172719.jpg
I want to draw a LinearGradient background for QCombobox item when item was focused.
I can't use CSS do it.
Now I use the code like this: but it seems like that it LinearGradiented for all items as one;
QLinearGradient linearGradient2(0, 0, 0, 100);
linearGradient2.setColorAt(0, QColor(132, 132, 132, 0));
linearGradient2.setColorAt(0.96, QColor(132, 132, 32, 255));
p.setBrush(QPalette::Highlight, QBrush(linearGradient2));
this->setPalette(p);
Thanks a lot!
Added after 15 minutes:
The Qt deal with the 1st item, 2nd .. .. as a pic. I just want to do each item like the 1st one.
1:
http://blog.chinaunix.net/photo/94700_101202172658.jpg
2:
http://blog.chinaunix.net/photo/94700_101202172709.jpg
3:
http://blog.chinaunix.net/photo/94700_101202172719.jpg