Results 1 to 11 of 11

Thread: how to change backgroup color, button color and shape?

  1. #1
    Join Date
    Jun 2008
    Posts
    15
    Qt products
    Qt3
    Platforms
    Windows

    Default how to change backgroup color, button color and shape?

    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
    Attached Files Attached Files
    Last edited by jacek; 12th June 2008 at 01:24. Reason: moved code to attachment

  2. #2
    Join Date
    Jun 2008
    Location
    Saint-Petersburg
    Posts
    50
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to change backgroup color, button color and shape?

    Hello!
    I don't find this parts of code but i can to prompt how to change style(for example background-color of buttons)!
    Qt Code:
    1. QString color = Qt::red;
    2. QString style = "* { background-color: ";
    3. style += color;
    4. style += " }";
    5. QButton btnColor = new QButton(this);
    6. btnColor -> setStyleSheet(style);
    To copy to clipboard, switch view to plain text mode 
    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!

  3. #3
    Join Date
    Jun 2008
    Posts
    15
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: how to change backgroup color, button color and shape?

    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.

  4. #4
    Join Date
    Jun 2008
    Posts
    15
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: how to change backgroup color, button color and shape?

    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.
    Attached Images Attached Images

  5. #5
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to change backgroup color, button color and shape?

    Quote Originally Posted by lzha022 View Post
    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.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to change backgroup color, button color and shape?

    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.

  7. #7
    Join Date
    Jun 2008
    Posts
    15
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: how to change backgroup color, button color and shape?

    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.

  8. #8
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to change backgroup color, button color and shape?

    i think you should "search" your question first in the forum and experiment. There are related threads to your question.

  9. #9
    Join Date
    Jun 2008
    Posts
    15
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: how to change backgroup color, button color and shape?

    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

  10. #10
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to change backgroup color, button color and shape?

    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

  11. #11
    Join Date
    Jun 2008
    Posts
    15
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: how to change backgroup color, button color and shape?

    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.


    Quote Originally Posted by aamer4yu View Post
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.