[英]Qt, get data inside a child widget from another child widget
我在主窗口中创建新的cad小部件:
glWidget = new MeshViewerWidget(this);
然后是我的文本视图小部件:
tbl = new tableView( this );
在我的主窗口中,我可以使用以下方法进行网格划分:
glWidget->mesh();
我如何在tableview.cc中获取它? ty
您可以使用QObject
的findChildren
函数并获取可转换为给定类型的小部件的所有子级的列表。 例如
QList<QTableView*> allTableViews = glWidget->findChildren<QTableView *>();
// Iterate in order to find the table view either by checking the name, the parent etc....
Simon提出的另一种方法是,将子类添加到公共控件中,然后将其添加到您希望从顶层小部件可访问的成员。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.