Get back old functional button design, even on Windows 10

Find and share HowTos to various installations / configurations!
7 posts • Page 1 of 1
agruber
Posts:147
Joined: Tue Sep 07, 2010 2:52 pm

Get back old functional button design, even on Windows 10

Post by agruber »

Hello,

Some of you might have noticed, that there is no Windows classic style anymore in Windows 10. So when you use the background of a button to signal something, like an alarm, only a small border is changed and it is not really that good visible.

You can use "-style windows" or "-style fusion" as UI startup option. However this changes all UI elements which you probably do not want.

A way to get back the old style, but functional button, is to use a stylesheet.

Just add a stylesheet.css in the config directory of your project containing the following:

Code: Select all

QPushButton
{
    background-color: rgb(214, 211, 206);
}
The color code in the above example is the default one from the Windows classic style.

It will look like the Windows classic style independent from the OS, the screen was taken from an openSuse machine:
Image

You will see the various differences and benefits better once you set the background color of the button, see the examples included below. Note, the above button always uses the stylesheet and the below button is the unchanged OS button.

With that change you are able to also have influence on the button display on a webclient (or mobile UI), where you typically have no information which Windows style a user uses.

With the type option in the stylesheet you can apply this change only to specific buttons, if you like.

Hope that helps some of you.

BR,
Andreas Gruber
Head of WinCC OA customer care

Windows 10
Image

Windows 7 AERO
Image

Centos7 - GNOME
Image

Windows 7 classic style
Image

OpenSuse 13.2 - KDE
Image
Attachments
win7_classic.png
Centos7_gnome.png
win7_aero.png
win10.png
opensuse13.png
old_style_button.png

RudiKreiner
Posts:198
Joined: Mon May 16, 2011 2:10 pm

Re: Get back old functional button design, even on Windows 10

Post by RudiKreiner »

We had the same problem and a colleague fixed it with a style sheet containing this:

QPushButton
{
background-color: #EFEFEF;
}

Same difference, right?

fmulder
Posts:330
Joined: Wed Feb 03, 2010 9:46 am

Re: Get back old functional button design, even on Windows 10

Post by fmulder »

The stylesheets are an extremely powerfull tool to change the appearance of your gui. we use it to make buttons that have a color scheme that a normal button won't even do. ( For example: we have a yellow disabled(!) button).

We use the 'Typename' property of the button. This has the advantage that we can selectively change buttons. The example below will only affect the buttons where you type the value "YELLOWBUTTON" in the property 'Typename'.

Code: Select all

QPushButton[type = "YELLOWBUTTON"]
{
  border: 1px solid rgb(0,0,0);
  border-radius: 1px;
  font-family: "Arial Narrow";
  font-size: 15px;
  
  background:rgb(220,220,220);
}
We even use script code to change the style of the buttons by assigining a different 'Typename' to the button 'on the fly'.

Stylesheets are pretty awesome !

share the fun
Frenk

agruber
Posts:147
Joined: Tue Sep 07, 2010 2:52 pm

Re: Get back old functional button design, even on Windows 10

Post by agruber »

Frenk Mulder wrote:
We even use script code to change the style of the buttons by assigining a different 'Typename' to the button 'on the fly'.
On vacation I finally have time to work on my home automation.

I have tried to change stylesheet on a button during runtime on the fly, but maybe I am missing something.

I have used a very basic code, like:

Code: Select all

  setValue("btn", "type", "myAlternateStyle");
I do not get an error message and the style does not change. How did you do it, Frenk?

BR,
Andreas

fmulder
Posts:330
Joined: Wed Feb 03, 2010 9:46 am

Re: Get back old functional button design, even on Windows 10

Post by fmulder »

I'm sure you forgot the last line of code:

Code: Select all

  // assign some styles
  buttonOpen.type  = "BUTTONYELLOW";
  buttonClose.type = "BUTTONRED";
  
 // Must call this line so that change has effect !
  setApplicationProperty( "styleSheet", getApplicationProperty( "styleSheet" ));
Share the Fun !
Frenk Mulder

agruber
Posts:147
Joined: Tue Sep 07, 2010 2:52 pm

Re: Get back old functional button design, even on Windows 10

Post by agruber »

Thanks, that worked perfectly fine.

I will try to find out, if there is a better way to do a refresh the style of a single object.

BR,
Andreas

agruber
Posts:147
Joined: Tue Sep 07, 2010 2:52 pm

Re: Get back old functional button design, even on Windows 10

Post by agruber »

Beginning with the upcoming patches for 3.14 and 3.15 we will support "-style windows" again.

You can still use the example in the top post if you just want to have the "old" button design which enables changing of the background.

7 posts • Page 1 of 1