Qt 对象的名称必须是唯一的吗?
QObject::objectName
属性对于整个应用程序必须是唯一的吗?例如,假设我在某个地方有一个名为“new”的按钮,那么我将在其他地方创建一个也称为“new”的 QShortcut。这会给Qt带来问题吗?
我知道如何正确命名对象(所谓的“新”不是一个好名字),但我只是想知道我是否需要格外小心。
Does the QObject::objectName
property have to be unique for the whole application? For example, let's say I have button somewhere called "new", then somewhere else I'm going to create a QShortcut also called "new". Is it going to cause a problem to Qt?
I know about properly naming objects (something called "new" is not a good name) but I just want to know whether I need to be extra careful or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对象名称不需要是唯一的。然而,在命名对象时,我至少可以考虑两件事:
Object names are not required to be unique. However, there are at least two things I can think of to consider when naming your objects:
其他需要考虑的事项:
Other things to consider:
QTimer
s and such.