pazduha
pazduha

Reputation: 147

Qt, get data inside a child widget from another child widget

I create new cad widget in my mainwindow:

glWidget = new MeshViewerWidget(this);

and then my text view widget:

tbl = new tableView( this );

in my mainwindow i can get my mesh with:

glWidget->mesh();

How do i get it in my tableview.cc? ty

Upvotes: 0

Views: 1292

Answers (1)

pnezis
pnezis

Reputation: 12321

You could use the findChildren function of QObject and get a list of all children of a widget that can be casted to the given type. Eg

QList<QTableView*> allTableViews = glWidget->findChildren<QTableView *>();
// Iterate in order to find the table view either by checking the name, the parent etc....

Another approach would be the one Simon suggests, subclassing and adding public access function to the members you want to be reachable from top level widgets.

Upvotes: 1

Related Questions