View Full Version : Removing same type of Widgets from QWorkspace

8th May 2009, 10:03
I have a QWorkspace.

I can generate large amounts of the same type of widget: "DetailSummaryWdg" and add them to the workspace. I want to provide an action to this widget to close all widgets of the same type, i.e., the user wants to close all the detailsummaries with the click of a button.

I have tried traversing the children() of the QWorkspace and compare both objectName and metaObject()->className(), but when the objectName() of the object is "DetailSummaryWdg", the className from the same widget in the workspace is QWorkspaceChild and its objectName is qt_workspacechild.

Any suggestions on how I can remove all widgets of the same type/class?

8th May 2009, 10:53
Maybe it's an idea to subclass the class from which DetailSummaryWdg is created..

Then adding a Type variable to that class (int or something)

#define TYPE_DETAIL_SUMMARY 1010 // or something else you like

class DetailSummaryWidget : public BaseClass
int Type;


When traversing the windows in the workspace, you can check on that particular Type variable if the window needs to be closed.

Just an idea :) Maybe there are more ways....