QMainWindow().centralWidget() always gives me zero ....
I need to access to this widget from any point on my app...
What I'm doing bad ? Thanks.
QMainWindow().centralWidget() always gives me zero ....
I need to access to this widget from any point on my app...
What I'm doing bad ? Thanks.
You getting central widget of new QMainWidget instance, obviously it is empty. Call centralWidget() of your QMainWidget subclass (often it's called MainWidget). To access something through all application you can use, for example, singleton.
Oleg Shparber
As Oleg says, the central widget of a default constructed QMainWindow is not likely to be useful. Further, you seem to be expecting QMainWindow::centralWidget() to be static: it isn't and cannot reasonably be so.
Provide public functions that provide the interface for external entities to operate on the private UI widgets of the main window. Generally these functions will provide a controlled way to achieve some higher level abstract effect and not a mechanism to violate encapsulation.I need to access to this widget from any point on my app...
Probably perpetuating a bad design.What I'm doing bad ? Thanks.
Bookmarks