[英]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.