Difference between revisions of "Documentation/Nightly/Developers/Tutorials/MigrationGuide/ObsoleteCodeRemoval"
From Slicer Wiki
Line 2: | Line 2: | ||
This section documents suggested code changes after removing support for a particular features. Each category has a short description, code snippets, a suggested upgrade path, and references to relevant commits. | This section documents suggested code changes after removing support for a particular features. Each category has a short description, code snippets, a suggested upgrade path, and references to relevant commits. | ||
+ | |||
+ | ===Qt >= 5.6.0: cpp: QDesignerCustomWidgetInterface header include=== | ||
+ | |||
+ | Before: | ||
+ | |||
+ | #include <QtGlobal> | ||
+ | #if(QT_VERSION < QT_VERSION_CHECKS(5, 6, 0)) | ||
+ | // Obsolete Qt4 code | ||
+ | #include <QDesignerCustomWidgetInterface> | ||
+ | #else | ||
+ | // Qt5 code | ||
+ | #include <QtUiPlugin/QDesignerCustomWidgetInterface> | ||
+ | #endif | ||
+ | |||
+ | After: | ||
+ | |||
+ | #include <QtUiPlugin/QDesignerCustomWidgetInterface> | ||
+ | |||
+ | ===Qt >= 5.0.0: cpp: Q_PLUGIN_METADATA macro=== | ||
+ | |||
+ | Before: | ||
+ | |||
+ | class Q_SLICER_MODULE_SEGMENTATIONS_WIDGETS_PLUGINS_EXPORT qSlicerSegmentationsModuleWidgetsAbstractPlugin | ||
+ | : public QDesignerCustomWidgetInterface | ||
+ | { | ||
+ | #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) | ||
+ | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface") | ||
+ | #endif | ||
+ | Q_INTERFACES(QDesignerCustomWidgetInterface); | ||
+ | } | ||
+ | |||
+ | After: | ||
+ | |||
+ | <pre> | ||
+ | class Q_SLICER_MODULE_SEGMENTATIONS_WIDGETS_PLUGINS_EXPORT qSlicerSegmentationsModuleWidgetsAbstractPlugin | ||
+ | : public QDesignerCustomWidgetInterface | ||
+ | { | ||
+ | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface") | ||
+ | Q_INTERFACES(QDesignerCustomWidgetInterface); | ||
+ | } | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | ===Qt >= 5.0.0: Python: Simpler use of setSectionResizeMode=== | ||
+ | |||
+ | This migration guide points becomes obsolete: | ||
+ | [[Documentation/Nightly/Developers/Tutorials/MigrationGuide#Qt5:_Fix_error:_.E2.80.98class_QHeaderView.E2.80.99_has_no_member_named_.E2.80.98setResizeMode.E2.80.99]] | ||
+ | |||
+ | Before: | ||
+ | |||
+ | _setSectionResizeMode(self.horizontalHeader(), 0, qt.QHeaderView.Stretch) | ||
+ | def _setSectionResizeMode(header, *args, **kwargs): | ||
+ | if version.parse(qt.Qt.qVersion()) < version.parse("5.0.0"): | ||
+ | header.setResizeMode(*args, **kwargs) | ||
+ | else: | ||
+ | header.setSectionResizeMode(*args, **kwargs) | ||
+ | |||
+ | After: | ||
+ | |||
+ | self.horizontalHeader(0, qt.QHeaderView.Stretch) |
Revision as of 20:35, 8 March 2019
Home < Documentation < Nightly < Developers < Tutorials < MigrationGuide < ObsoleteCodeRemovalContents
Obsolete Code Removal
This section documents suggested code changes after removing support for a particular features. Each category has a short description, code snippets, a suggested upgrade path, and references to relevant commits.
Qt >= 5.6.0: cpp: QDesignerCustomWidgetInterface header include
Before:
#include <QtGlobal> #if(QT_VERSION < QT_VERSION_CHECKS(5, 6, 0)) // Obsolete Qt4 code #include <QDesignerCustomWidgetInterface> #else // Qt5 code #include <QtUiPlugin/QDesignerCustomWidgetInterface> #endif
After:
#include <QtUiPlugin/QDesignerCustomWidgetInterface>
Qt >= 5.0.0: cpp: Q_PLUGIN_METADATA macro
Before:
class Q_SLICER_MODULE_SEGMENTATIONS_WIDGETS_PLUGINS_EXPORT qSlicerSegmentationsModuleWidgetsAbstractPlugin : public QDesignerCustomWidgetInterface { #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface") #endif Q_INTERFACES(QDesignerCustomWidgetInterface); }
After:
class Q_SLICER_MODULE_SEGMENTATIONS_WIDGETS_PLUGINS_EXPORT qSlicerSegmentationsModuleWidgetsAbstractPlugin : public QDesignerCustomWidgetInterface { Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface") Q_INTERFACES(QDesignerCustomWidgetInterface); }
Qt >= 5.0.0: Python: Simpler use of setSectionResizeMode
This migration guide points becomes obsolete: Documentation/Nightly/Developers/Tutorials/MigrationGuide#Qt5:_Fix_error:_.E2.80.98class_QHeaderView.E2.80.99_has_no_member_named_.E2.80.98setResizeMode.E2.80.99
Before:
_setSectionResizeMode(self.horizontalHeader(), 0, qt.QHeaderView.Stretch) def _setSectionResizeMode(header, *args, **kwargs): if version.parse(qt.Qt.qVersion()) < version.parse("5.0.0"): header.setResizeMode(*args, **kwargs) else: header.setSectionResizeMode(*args, **kwargs)
After:
self.horizontalHeader(0, qt.QHeaderView.Stretch)