PDA

View Full Version : how to change backgroup color, button color and shape?



lzha022
11th June 2008, 06:20
Hi, i am new here and i am also new to QT. As the person who designed the UI has left and i was asked to change the backgroup color, button color and shape. I spent a few hours reading the code, still can not figure out how to do that.
Please find attached the myStyle file - i think this files controls all colors and shape thing.
Could anyone please tell which lines of code are related to backgroup color change and which one are related to button color and shape change.
thanks a lot.
Alison

AD
11th June 2008, 16:49
Hello!
I don't find this parts of code but i can to prompt how to change style(for example background-color of buttons)! :)


QString color = Qt::red;
QString style = "* { background-color: ";
style += color;
style += " }";
QButton btnColor = new QButton(this);
btnColor -> setStyleSheet(style);

This method is used for changing other styles so as

P.S. Sorry by my bad english! I'll be one's utmost to learn english better!

lzha022
11th June 2008, 23:26
Hi,
Thank you for the reply.
I am afraid your post does not apply to my situation.
All i know from the previous designer is that this file controls all the interface thing.

By the way, your english is not bad. And my English is not good either.

lzha022
11th June 2008, 23:39
The project i am working on is big, it has lots of windows and buttons.
Attached please find what the current window and button look like. And i want to change both the window`s color and the button`s color and shape.

pherthyl
12th June 2008, 01:30
Hi, i am new here and i am also new to QT. As the person who designed the UI has left and i was asked to change the backgroup color, button color and shape. I spent a few hours reading the code, still can not figure out how to do that.
Please find attached the myStyle file - i think this files controls all colors and shape thing.
Could anyone please tell which lines of code are related to backgroup color change and which one are related to button color and shape change.
thanks a lot.
Alison

Seems pretty straightforward. That's the custom style, and most of the colours are defined at the top (in the metalcolors array). Just change those colours and experiment. Shape will be a bit more difficult, depends on how radical you want to get, but you're definitely looking at the right file.

jacek
12th June 2008, 01:35
It seems that myStyle::drawButton() is responsible for the shape of the button, while metalColor array holds colours used to fill it.

P.S. Please don't post the same thread twice in different sections.

lzha022
12th June 2008, 04:11
Thanks everyone for the reply.

Yes, i tried to change metalColor, and the button colors changed. But i am not clear why there are 5 colors in metalColor?
I will need to find out how to change the shape of the buttons.
How about the background style and color? Can you tell me which part code is related to that?
Thanks.

Sorry for posting the question twice.

triperzonak
12th June 2008, 08:41
i think you should "search" your question first in the forum and experiment. There are related threads to your question. :D

lzha022
16th June 2008, 00:29
I looked at marble.xpm, it is the backgroup style. I tried to get another image file 'style.xmp'. I included this file at the top and changed the following code
QPixmap background(marble_xpm);
to
QPixmap background(style_xpm);
But i got an error ' undeclared identifier'
I even tried to back up the marble.xpm file and renamed style.xmp to marble.xmp and i still got ' undeclared identifier' error.
could anyone please tell me which part i am missing?
Thanks

aamer4yu
16th June 2008, 06:30
Are u not confusing between xpm and xmp ??

By the way, I guess renaming a xpm file doesnt work. Open a xpm file with notepad, and you will see some char[] = {}; defined. The name of this char is used I guess.
Am not sure how you are using the xpm, but this is the reason i can guess. Check the name of the xpm in notepad ( filename and char[] name)

Hope it helps :)

lzha022
16th June 2008, 23:25
Thank you for the reply. I do not know what xmp is (have i typed xmp before?), but my program is using xpm. You are right the name is saved at the beginning of the xpm file. With a new xpm file, i can change the background style.



Are u not confusing between xpm and xmp ??

By the way, I guess renaming a xpm file doesnt work. Open a xpm file with notepad, and you will see some char[] = {}; defined. The name of this char is used I guess.
Am not sure how you are using the xpm, but this is the reason i can guess. Check the name of the xpm in notepad ( filename and char[] name)

Hope it helps :)