PDA

View Full Version : Regarding qlineargradient



jjbabu
14th April 2009, 07:24
Hi,


background: qlineargradient(x1:0, y1:0, x2:1, y2:1,
stop:0 white, stop: 0.4 gray, stop:1 green)

Using the above syntax i can able to change the my widget(push button) background color from top-left corner to bottom-right corner.
But my requirement is i have to fix push button top layer(i.e x1:0, y1:0, x2:0, y2:1) with one color and bottom layer( i.e x1:1, y1:0, x2:1, y2:1)with different color.How can i achieve this? Is it possible or not?

thank you.

wysota
14th April 2009, 22:34
Could you provide an image of what you want?

jjbabu
15th April 2009, 06:01
Hi wysota,
For look and feel customization i am using style sheet concept in QT.my requirement is as i mentioned in my previous post,as per your requirement i attached image of my requirement in with file name "Button.png".3142

few more questions i need to ask u.How i can change the normal push button shape.me requirement shapes are attached with the file names of "Le1.png" & "Le2.png".
3143

3144

I have to add search icon to the combo box in the right corner besides the drop down icon.when i was using below code in "change style sheet" my search icon is overlapping with drop down icon.i am not able to align icon properly.actual my requirement image is attached with the file name"search_line.png"
3145


background: url(F:/QT/4.4.3/1239617088_bullet_arrow_up.png);
background-position: bottom right;
background-repeat: no-repeat;


NOTE:
1)please open .png files using "Microsoft office picture manager" for better look and feel appearance.
2)for all above look and feel consideration purpose i used QT designer's widget "change style sheet" property in my project.

thanks in advance.

jjbabu
15th April 2009, 06:05
Please consider this attachment for above post
"search line.png"

thank u.

wysota
15th April 2009, 07:39
I still don't understand the problem with the button :) You mean you want a button with a sharp border between two colours (which doesn't look like the one you posted) or a smooth transition between two gradients going in different directions throughout the whole button? If the latter, then this is not a linear gradient anymore. You can either try a conical gradient or just subsitute the gradient with an image which is also the answer to your second question. Transparent parts of the button have to be transparent in the image and/or you need to provide a mask for the button using QWidget::setMask().

Lykurg
15th April 2009, 08:20
Another option might be you design your buttons in a graphical application and then set it to your buttons. See "QPushButton and images" in the "Qt Style Sheets Examples".

jjbabu
15th April 2009, 09:21
I did it man!!!!!!!!!!thank u.
wysota,that button coloring also solved
inspite of putting below code


background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 white, stop: 0.5 #daf4f0, stop:1 #daf4f0);

I modified like this


background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1,
stop:0 white, stop: 0.5 #daf4f0, stop:1 #daf4f0);

using this linearly 50%top layer one color and remaining 50% different color.


what about that combo box search icon alignment.please provide solution for that?
thanks a lot....