Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我的 gridLayout 中有元素,我可以获得对该对象的引用,如果是,我需要使用哪个函数?对 gridLayout 中的对象执行一些操作是个好主意吗?还是有其他更好的语言习语?
不,您无法从布局中获取对项目的引用。但是,您可以从保存按钮的容器中。更好的解决方案可能是在更高级别的范围内保留对按钮的引用,以便以后能够访问它。
LayoutManager除非它特别支持它,否则您无法从中获取东西,并且GridLayout不支持。
LayoutManager
GridLayout
如果您将Components 放入 aContainer那么您可能无论如何都会引用它们。你不能传递这个参考吗?
Component
Container