有没有办法在C ++中自定义按钮的样子?

时间:2021-12-11 10:29:47

I have programmed in HTML, Java, CSS, C++, VB, an Python.
I'm looking to make button that looks completely the way I want it to look!
Like in HTML+Java+CSS, I can do that very thing!
I'm using Netbeans IDE. I was about to just use OpenGL to do the GUI programming for my programs, since it is so hard to find information on customized GUIs.
I just want to learn how to make the image and give button functionality to it. I want to be able to make the shape, color, and effects (when clicked, hovered over, etc).

我用HTML,Java,CSS,C ++,VB,Python编写了程序。我正在寻找完全按照我想要的方式制作按钮!就像在HTML + Java + CSS中一样,我可以做到这一点!我正在使用Netbeans IDE。我即将使用OpenGL为我的程序进行GUI编程,因为很难找到有关自定义GUI的信息。我只想学习如何制作图像并为其提供按钮功能。我希望能够制作形状,颜色和效果(点击,悬停等)。

Oh, and I program in Ubuntu Linux!

哦,我在Ubuntu Linux中编程!

Any help would be appreciated!

任何帮助,将不胜感激!

2 个解决方案

#1


0  

Qt is a good idea, but you won't learn how it works, though it's not really important and far easier like that. Using C++ you will have libraries that respect the encapsulation principle, so you won't know at the first sight how do is work, just how to use it.

Qt是一个好主意,但你不会知道它是如何工作的,尽管它并不是那么重要且容易得多。使用C ++,您将拥有尊重封装原则的库,因此您不会在第一眼就知道它是如何工作的,只是如何使用它。

If you really want to code a button yourself, you can take a 2D drawing library such as SFML, with which you'll draw your button and handle events on it.

如果你真的想自己编写一个按钮,你可以使用一个2D绘图库,比如SFML,用它来绘制你的按钮并处理它上面的事件。

#2


0  

When I wrote a custom button class for my app, we (the C++ developers) were given PNG images from the designer department. They are much better with tools like Photoshop then we developers. We just showed image1.PNG by default, image2.PNG when the mouse was over the button ("hover"), and image3.PNG when the mouse was over the button and pressed. Drawing? Not necessary.

当我为我的应用程序编写自定义按钮类时,我们(C ++开发人员)获得了设计师部门的PNG图像。使用像Photoshop这样的工具,我们的开发人员会更好。默认情况下我们只显示image1.PNG,当鼠标悬停在按钮上时显示image2.PNG(“悬停”),当鼠标悬停在按钮上时按下并显示image3.PNG。画画?不必要。

Color is trivial for designers. Shape isn't hard either. PNGs are rectangular, but can be transparent. So rounded edges are just a matter of a few transparent pixels there.

颜色对于设计师来说是微不足道的。形状也不难。 PNG是矩形的,但可以是透明的。所以圆形边缘只是几个透明像素的问题。

#1


0  

Qt is a good idea, but you won't learn how it works, though it's not really important and far easier like that. Using C++ you will have libraries that respect the encapsulation principle, so you won't know at the first sight how do is work, just how to use it.

Qt是一个好主意,但你不会知道它是如何工作的,尽管它并不是那么重要且容易得多。使用C ++,您将拥有尊重封装原则的库,因此您不会在第一眼就知道它是如何工作的,只是如何使用它。

If you really want to code a button yourself, you can take a 2D drawing library such as SFML, with which you'll draw your button and handle events on it.

如果你真的想自己编写一个按钮,你可以使用一个2D绘图库,比如SFML,用它来绘制你的按钮并处理它上面的事件。

#2


0  

When I wrote a custom button class for my app, we (the C++ developers) were given PNG images from the designer department. They are much better with tools like Photoshop then we developers. We just showed image1.PNG by default, image2.PNG when the mouse was over the button ("hover"), and image3.PNG when the mouse was over the button and pressed. Drawing? Not necessary.

当我为我的应用程序编写自定义按钮类时,我们(C ++开发人员)获得了设计师部门的PNG图像。使用像Photoshop这样的工具,我们的开发人员会更好。默认情况下我们只显示image1.PNG,当鼠标悬停在按钮上时显示image2.PNG(“悬停”),当鼠标悬停在按钮上时按下并显示image3.PNG。画画?不必要。

Color is trivial for designers. Shape isn't hard either. PNGs are rectangular, but can be transparent. So rounded edges are just a matter of a few transparent pixels there.

颜色对于设计师来说是微不足道的。形状也不难。 PNG是矩形的,但可以是透明的。所以圆形边缘只是几个透明像素的问题。