typedef ExtensionFactory<QDesignerContainerExtension, QStackedWidget, QStackedWidgetContainer> QDesignerStackedWidgetContainerFactory;typedef ExtensionFactory<QDesignerContainerExtension, QTabWidget, QTabWidgetContainer> QDesignerTabWidgetContainerFactory;typedef ExtensionFactory<QDesignerContainerExtension, QToolBox, QToolBoxContainer> QDesignerToolBoxContainerFactory;typedef ExtensionFactory<QDesignerContainerExtension, QScrollArea, QScrollAreaContainer> QScrollAreaContainerFactory;typedef ExtensionFactory<QDesignerContainerExtension, QDockWidget, QDockWidgetContainer> QDockWidgetContainerFactory;
QExtensionManager *mgr = new QExtensionManager(this);const QString containerExtensionId = Q_TYPEID(QDesignerContainerExtension);QDesignerStackedWidgetContainerFactory::registerExtension(mgr, containerExtensionId);QDesignerTabWidgetContainerFactory::registerExtension(mgr, containerExtensionId);QDesignerToolBoxContainerFactory::registerExtension(mgr, containerExtensionId);QDockWidgetContainerFactory::registerExtension(mgr, containerExtensionId);QScrollAreaContainerFactory::registerExtension(mgr, containerExtensionId);
...if (QDesignerContainerExtension *container = qt_extension<QDesignerContainerExtension*>(core()->extensionManager(), widget)) { for (int i=0; i<container->count(); ++i) { QWidget *page = container->widget(i); ... } }...
C++ (Qt)// простой примерCFactoryObject * CMyFactory::GetByID( int ID ){ TIterator it = mMap.find(ID); return (it == mMap.end()) ? 0 : it.second->Create(); }
C++ (Qt)// чуть сложнееCFactoryObject * CMyFactory::GeLoader( int format ){ TIterator it; for (it = mMap.begin(); it != mMap.end(); ++it) { CLoader * loader = it.second->Create(); if (loader->AcceptFormat(format)) return loader; delete loader; }}
C++ (Qt)// простой примерCFactoryObject * CMyFactory::GetByID( int ID ){ TIterator it = mMap.find(ID); return (it == mMap.end()) ? 0 : it->second.Create(); }