Results 1 to 4 of 4

Thread: Last pressed QPushButton looses alpha-transparency setting

  1. #1
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Question Last pressed QPushButton looses alpha-transparency setting

    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

  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: Last pressed QPushButton looses alpha-transparency setting

    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.
    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. The following user says thank you to wysota for this useful post:

    mmaaxx (8th September 2011)

  4. #3
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Last pressed QPushButton looses alpha-transparency setting

    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).

  5. #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: Last pressed QPushButton looses alpha-transparency setting

    Quote Originally Posted by mmaaxx View Post
    (I was setting no focus and no default and no autodefault in the code).
    Those can change as a result of clicking the 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.


Similar Threads

  1. Replies: 9
    Last Post: 8th November 2011, 16:54
  2. Replies: 4
    Last Post: 16th September 2011, 03:10
  3. Replies: 0
    Last Post: 8th November 2010, 22:17
  4. Removing pressed effect from a QPushButton
    By Luc4 in forum Qt Programming
    Replies: 3
    Last Post: 14th August 2010, 12:43
  5. Delay Loop until a QPushButton pressed
    By ljshap in forum Newbie
    Replies: 6
    Last Post: 17th January 2009, 17:30

Tags for this Thread

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.