使用 Qt 将平面图像转换为带有 3D 高光的漂亮圆形图像,就像 iPhone 一样
在 iPhone 上,您为应用程序图标提供 45x45 平面图像,SDK 会自动为您舍入并突出显示它,从而赋予其新的 3D 效果。有谁有关于如何使用 Qt4 API 进行模拟的示例代码或建议吗?谢谢,--DD
On the iPhone, you give it your 45x45 flat image for the app icon, and the SDK rounds and highlights it for you automatically, giving it a new 3D effect. Does anyone have sample code or recommendations on how to emulate this using Qt4 APIs? Thanks, --DD
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想要 iPhone 应用程序图标的完整效果:圆角矩形、赋予其 3D 外观的微妙渐变和光泽,我不确定样式表是否可以满足您所要求的所有要求。但也许可以,如果你可以将两个图像叠加在一起。一种可能是具有透明度的圆形 3D 蒙版图像,然后您只需将 45X45 图像放在其后面即可。但是,我现在不知道 qstylesheets 的可扩展性如何。
然而,另一种选择是使用 QPainter。它绝对可以满足您的所有要求。基本上你想要做的是覆盖你的小部件、QPushButton、QLabel...等的paintEvent()。并使用源图像自己绘制。以下是我在自定义绘制 QPushButton 时所做的 wiki 条目的链接,以使其具有 Windows Aero 外观,这与 iphone 应用程序图标没有什么不同: http://wiki.qtcentre.org/index.php?title=AeroButton
这里是类中的paintEvent(),给你一个起点。一旦你进入它,使用助手,它就非常简单:
I'm not sure a style sheet could do all you are asking for, if you want the full effect of the iphone app icons: the rounded rectangle, the subtle gradient to give it the 3D look, and the shine. But perhaps it could, if you could overlay two images on top of one another. One could be the rounded 3D mask image with transparency, then you just put your 45X45 image behind it. But then, I don't know how extensible qstylesheets are at this point.
However, another alternative is to use QPainter. It can definitely do all you require. Basically what you would want to do is override the paintEvent() of your widget, QPushButton, QLabel...etc. and draw it yourself using the source image. Here is a link to a wiki entry I did on custom-painting a QPushButton to give it an Windows Aero look, which is not dissimilar to the iphone app icon: http://wiki.qtcentre.org/index.php?title=AeroButton
And here is the paintEvent() from the class, to give you a starting point. Once you get into it, using the Assistant, it's pretty straightforward:
(这是一个建议,因为我还没有真正尝试过)
样式表即:
我认为这将是最简单的解决方案,因为它会给你一个可点击的qpushbutton。
参考助手如何写样式表...
(This is a suggestion because I have not actually tried it)
Stylesheet i.e :
I think this would be the easiest solution, as it would give you a clickable qpushbutton.
Refer to the assistant on how to write stylesheets...