PDA

View Full Version : Issue with masking QWidgets



JimDaniel
2nd November 2007, 03:27
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

kernel_panic
2nd November 2007, 07:32
if you just want to use it under windows look at this:
http://wiki.qtcentre.org/index.php?title=ARGB-Widgets

JimDaniel
2nd November 2007, 19:28
Hey, I'm trying to maintain cross-platform-ability for this app, but thanks for the article in any case. Great stuff.

pherthyl
2nd November 2007, 19:42
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.

JimDaniel
2nd November 2007, 20:03
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...

pherthyl
2nd November 2007, 20:20
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.

pherthyl
2nd November 2007, 20:23
This may also be helpful:
http://dev.openwengo.com/trac/openwengo/trac.cgi/wiki/SkinStyle