Frage

I develop an app with plugins. Each plugin should have it's own settings window (QDialog type).

If plugin's settings form was included in main project, I'll simply create it with passing main form as parent as said here: http://developer.qt.nokia.com/doc/qt-4.8/qdialog.html#QDialog (and in Google results for this problem).

But when QDialog declared in separated plugin, I think that it's ugly and insecure to pass main form as parent from main app to plugin instance.

Any ideas? Stub QWidget?

War es hilfreich?

Lösung 2

Ok, I'd just create stub QWidget as suggest earlier:

QWidget *a = new QWidget();
settingsForm = new OpenFolderSettings(a);
...
delete settingsForm;
delete a;

So now dialog doesn't show button on taskbar. Also, no new window appear.

Andere Tipps

I have a small idea. This is different approach but it might work in your case too. As I understand you are trying to create settings manager for you application. You can use QSettings for example and store settings for each plugin in different subgroup. For example you have a main app settings and two other plugins.

[Main App]
key1=val1
key2=val2

[Plugin1]
key1=val1
key2=val2

[Plugin1]
key1=val1
key2=val2

This way you could easily construct a QDialog in your main appication and change/save the settings. In turn the main application notifies plugins via signal that settings have changed and need to be reloaded. This way you encapsulate you main application from your plugins.

update

Thanks for a quick feedback. The approach I proposed is MainApplication centric but it can be redesigned to be decentralized. Since QSettings is application specific your plugins can store their settings in one configuration with main app as before. One modification I would make is the following. You can create a QDialog within your plugin and modify the settings without necessity for main app to be aware of this process.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top