Results 1 to 4 of 4

Thread: why StyleSheet color setting changine button shape?

  1. #1
    Join Date
    Apr 2007
    Location
    Rakovnik, Czech Republic
    Posts
    175
    Thanks
    43
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default why StyleSheet color setting changine button shape?

    Hey, I'm trying to do a rather simple thing: control the color of my QPushButtons when isUp, isDown, hover, etc. I'm doing this:

    Qt Code:
    1. myPb->setStyleSheet("QPushButton { background: rgb(230,230,230)}");
    To copy to clipboard, switch view to plain text mode 

    which works, but changes the shape & look/feel of the buttons from normal to rectangular... best explained by looking at the attached image. "Co2 Hist" and "Co2 Proj" are the buttons with the setStyleSheet functions. The others are left alone/default.

    Can anyone suggest the simplest way to simply have the buttons look as they normally do, but with my own custom colors?
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: why StyleSheet color setting changine button shape?

    Because regular XP and Vista buttons don't support setting colours. So if the colour is to be set, an artificial button style has to be used. This is the case not only with Qt but with XP and Vista in general. See a web browser with a form that has a coloured button.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2007
    Location
    Rakovnik, Czech Republic
    Posts
    175
    Thanks
    43
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: why StyleSheet color setting changine button shape?

    OK, so when "artificial button style" used: why does it look so different from the winXP style? What can I do to make it look like the winXP style?


    The real problem: the button colors in their original format are fine, but people are complaining to me that they cannot tell sometimes whether a button (QPushButton) is pushed or not. So all I really want to do is make a pushed button look a little darker... so that it will stand out more as being pushed. Any advice appreciated.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: why StyleSheet color setting changine button shape?

    Quote Originally Posted by vonCZ View Post
    OK, so when "artificial button style" used: why does it look so different from the winXP style?
    Because the winxp style reacts on native skins that may be applied to it on the system level. There is no way Qt could emulate it all without extra effort. And there is no emulation on the system level for it. Blame Microsoft

    What can I do to make it look like the winXP style?
    You can style it yourself using images. But this won't emulate skins so if you deploy your application on a system with a different skin active, your button will still look odd.


    The real problem: the button colors in their original format are fine, but people are complaining to me that they cannot tell sometimes whether a button (QPushButton) is pushed or not. So all I really want to do is make a pushed button look a little darker... so that it will stand out more as being pushed. Any advice appreciated.
    How about implementing your own widget style or using one of the other widget styles available? Try running your application with "-style plastique" or "-style cleanlooks" parameters and see if it suits your needs.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    vonCZ (11th April 2009)

Similar Threads

  1. how to change backgroup color, button color and shape?
    By lzha022 in forum Qt Programming
    Replies: 10
    Last Post: 16th June 2008, 22:25
  2. shape of push button
    By Seema Rao in forum Qt Programming
    Replies: 23
    Last Post: 2nd April 2008, 01:05
  3. 3d button stylesheet?
    By MrGarbage in forum Qt Programming
    Replies: 2
    Last Post: 28th November 2007, 21:50

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.