PDA

View Full Version : update dockwidget contents



tuli
8th September 2012, 07:46
hi,

in one application, we are using QDockWindows to show different aspects/data of a loaded file.
The user can choose to create as many DockWidgets of the various available DOckWidgets, and he can place them where he likes.
The problem now is what to do when the user opens a new file.
In that case, the old content would have to be discarded and new content displayed,
without the docking arrangement being destroyed.

ATM, the docking widgets get their data from a single pointer to a file-instance.
it would be straight forward to zero that pointer, and simply assign one to the new instance. But how?

1)
a global signal UpdatePtr could be sent to all dockwidgets.
Not sure about that one. Would

emit UpdatePtr(newptr);
delete oldptr;

leave everyone enought time to really discard the old ptr?

2)
a global function that returns a ptr. That way, we would have to update one ptr instance only.
Not really a fan of global functions.

In either case, what do you think?

ChrisW67
9th September 2012, 23:47
In a single threaded program the signal call will not return until all the connected slots have been executed unless you use queued connections. Queued connections will be deferred until the event loop.

Another option is to use the same "file-instance" object to load the new file: the pointer doesn't change but you need to signal the views to refresh.