Results 1 to 7 of 7

Thread: Issue with masking QWidgets

  1. #1
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Issue with masking QWidgets

    Hi, I've been experimenting masking my QWidgets for different shaped buttons, windows...etc. One thing I can't figure out though is how to smooth out the borders of my masked image. The edges are always very pixellated no matter what resolution I set my mask image at.

    Is there some anti-aliasing effect I need to apply? Is such a thing even possible, or is this just the way it is...?

    Thanks for any advice you can give, Daniel

  2. #2
    Join Date
    Jan 2007
    Posts
    177
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Issue with masking QWidgets

    if you just want to use it under windows look at this:
    http://wiki.qtcentre.org/index.php?title=ARGB-Widgets

  3. #3
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Issue with masking QWidgets

    Hey, I'm trying to maintain cross-platform-ability for this app, but thanks for the article in any case. Great stuff.

  4. #4
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Issue with masking QWidgets

    For widgets, instead of masking, just paint your own in the shape you want them. This gets you nice antialiased corners. For shaped windows, there is no simple solution with antialiasing, either hack it or put up with the jaggies.

  5. #5
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Issue with masking QWidgets

    thanks pherthyl, can you clarify some things for me - do you mean I should override the paintEvent for the widget and do everything in there instead? What other methods would I need to override to say paint my QPushButton circular instead of a rectangle? I'm afraid I'm a little new at this...

  6. #6
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Issue with masking QWidgets

    Quote Originally Posted by JimDaniel View Post
    thanks pherthyl, can you clarify some things for me - do you mean I should override the paintEvent for the widget and do everything in there instead? What other methods would I need to override to say paint my QPushButton circular instead of a rectangle? I'm afraid I'm a little new at this...
    Yes, you would need to override the paintevent and draw the button there. That should be all that is necessary. However I doubt this is actually the best idea now that I think about it. If you are serious about providing a customized UI, you might want to go whole hog and write your own QStyle. http://doc.trolltech.com/4.3/qstyle.html

    Also look at the themes examples that come with Qt. This is probably the proper way to do it.

  7. #7
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Issue with masking QWidgets


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.