Results 1 to 7 of 7

Thread: QWidget::setMask() does not work on OS X side?

  1. #1
    Join Date
    Jun 2011
    Posts
    19
    Thanks
    3

    Unhappy QWidget::setMask() does not work on OS X side?

    I am creating a custom triangular button from a push button, using PNG/svgs as pictures.(alphas are set). However, when I attempt to set a mask( so you can only click on the triangle rather than the encompassing rectangle), it would not work in the MAC side, but it works perfectly fine in the windows side. Does anyone know what the issue is?

    here is a snippet of my code


    Qt Code:
    1. #include <QPixmap>
    2. #include <QBitmap>
    3. #include <QDebug>
    4. ...
    5.  
    6. ui->setupUi(this);
    7. QPixmap pixmap(":/Button1/triangle.svg");
    8. ui->pushButton->setMask(pixmap.mask());
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QWidget::setMask() does not work on OS X side?

    Did you check the bug tracker?
    I found this on a quick look:
    https://bugreports.qt.nokia.com//browse/QTBUG-16406
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    Dreamerzz (27th July 2011)

  4. #3
    Join Date
    Jun 2011
    Posts
    19
    Thanks
    3

    Default Re: QWidget::setMask() does not work on OS X side?

    i tried adding it without luck.

    Perhaps theres a difference when it comes to pushbuttons and labels?

    Also im not giving the pushbutton a pixmap but editing its style sheets

  5. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QWidget::setMask() does not work on OS X side?

    Also im not giving the pushbutton a pixmap but editing its style sheets
    That is not the code you posted.... ?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #5
    Join Date
    Jun 2011
    Posts
    19
    Thanks
    3

    Default Re: QWidget::setMask() does not work on OS X side?

    what i showed you was the masking part of the button.

    how the button looks was done with style sheets

    Qt Code:
    1. QPushButton#sampleButton:enabled{
    2. border-image: url(:/images/triangle.png);
    3. }
    4.  
    5. QPushButton#sampleButton:hover{
    6. border-image: url(:/images/triangle2.png);
    7. }
    8.  
    9. QPushButton#sampleButton:pressed {
    10. border-image: url(:/images/triangle3.png);
    11. }
    To copy to clipboard, switch view to plain text mode 

    sorry for the confusion!

  7. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QWidget::setMask() does not work on OS X side?

    Masking should not be effect by the stylesheet AFAIK.
    Comment out the stylesheet to make sure.
    I would also try using a png with alpha channel or even create a simple binary mask in code and try it.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  8. #7
    Join Date
    Jun 2011
    Posts
    19
    Thanks
    3

    Default Re: QWidget::setMask() does not work on OS X side?

    PNG alphamasks didn't work either

    hm..

Similar Threads

  1. Replies: 2
    Last Post: 14th July 2011, 15:17
  2. Replies: 1
    Last Post: 16th September 2010, 15:57
  3. QWidget setMask fully transparent.
    By bunjee in forum Qt Programming
    Replies: 5
    Last Post: 6th August 2009, 13:30
  4. QWidget::setMask: bug &/or help for workaround
    By ataffard in forum Qt Programming
    Replies: 3
    Last Post: 23rd May 2008, 07:34
  5. QPixmap::setMask() / QWidget::setMask()
    By yogeshm02 in forum Qt Programming
    Replies: 1
    Last Post: 25th February 2006, 11:34

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
  •  
Qt is a trademark of The Qt Company.