PDA

View Full Version : Last pressed QPushButton looses alpha-transparency setting



mmaaxx
6th September 2011, 19:10
Hi, I'm using qt 4.7 on Ubuntu 11.04 host, and Freescale i.MX 2.6.35 target, and I'm pretty successful, so far.

I have a form with multiple QPushButtons with NoFocus focus policy.
I want to make them red and semi-transparent, so I set CSS to background-color:rgba(255, 0, 0, 30%);

After I build and run the application for host pc (ubuntu 11 x32 running on Sun Virtual Box 4), everything works fine.
Buttons don't receive focus, they are semi-transparent, and stays like this, after I click them.

After this I build application for Freescale ARM9-based i.MX28 microcontroller, running Linux with 2.6.35 kernel.
When application starts - everything is fine (buttons are semi-transparent). Then I click on one of the buttons, and it becomes solid red. Then I click another button, and on OnRelease even it becomes solid red, and previously pressed button returns to semi-transparent state.

So, it almost sounds like Qt remembers last pressed button?, and use some different method(s) to paint it? And It seems like this method that paints last pressed button has a bug in alpha-channel display for the Embedded Build? Is there such setting under Qt?
Can I disable this, so the button remains transparent all the time?
This "last pressed" button has nothing to do with Focus, as it is disabled, and I tested it with Focus (it displays as dotted rectangle).

PS: My goal is to make QPushButton functional, but fully transparent. I used semi-transparency in the example above, just to show that the button only looses alpha-transparency, setting, when "last pressed".
Maybe there are simpler ways to make transparent buttons?

Thanks!
-Max

wysota
7th September 2011, 23:51
If you want transparent buttons then just subclass QAbstractButton and implement what you want. The effect you are having is related to the fact that a button can have different states and you are only setting a stylesheet for the default state. I don't know if your button is getting a focus or becomes a default button but its state changes and your stylesheet fails.

mmaaxx
8th September 2011, 16:34
Thanks wysota, that's what I end up doing. Also overloading and leaving empty paintEvent method worked.
But css didn't worked, it wasn't focus or default (I was setting no focus and no default and no autodefault in the code).

wysota
8th September 2011, 16:45
(I was setting no focus and no default and no autodefault in the code).
Those can change as a result of clicking the button.