Qt4/Qt5 neutral compilation fixes

Merged, abandoned or rejected pull requests are moved here to clear the main Pull Requests forum.
User avatar
f3nix
Posts: 330
Joined: Sat May 30, 2015 11:58 am

Qt4/Qt5 neutral compilation fixes

Postby f3nix » Mon Jan 04, 2016 10:02 pm

Hi,
this is the first batch of Qt5 compatibility changes. This changes are Qt4/Qt5 neutral (they do not use features specific to a particular Qt version).

Compilation and linking tested with:
1. Qt 4.8.7, GCC 5.3.1 - 64-bit
2. Qt 4.8.6 MSVC 2013 - 64-bit
3. Qt 5.5.1 GCC 5.3.1 64-bit
4. Qt 5.5.1 MSVC 2013 64-bit

The following changes since commit 273131c08857464fe7a140331afc864b7ae752f8:

Draft: finished new DXF importer - fixes #2205 (2016-01-04 18:01:34 -0200)

are available in the git repository at:

https://github.com/f3nix/FreeCAD.git qt4-qt5-neutral-1

for you to fetch changes up to ee78b4720c46dc63e02d31edf673f763f91fd8f2:

Change includes in Spreadsheet to be compatible with Qt5. (2016-01-04 22:35:32 +0100)

----------------------------------------------------------------
Mateusz Skowroński (10):
QString::toAscii() is obsolete in Qt5. Replace it with toLatin1().
QString::fromAscii() is obsolete in Qt5. Replace it with fromLatin1().
Qt::WFlags is obsolete in Qt5. Replace it with Qt::WindowFlags.
Make Base::Quantity known to QMetaType.
Qt4's qglobal.h defined TRUE and FALSE. Qt5 does not do it anymore. Replace it with true and false.
QKeySequence::operator QString() is obsolete in Qt5. Use toString(QKeySequence::NativeText) instead.
QObject::accessibleName() is not available in Qt5. Replace it with objectName().
QAbstractItemModel::reset() is obsolete in Qt5. Use beginResetModel() and endResetModel() instead.
Change includes in Quarter to be compatible with Qt5.
Change includes in Spreadsheet to be compatible with Qt5.

Code: Select all

 src/App/Application.cpp                            |   2 +-
 src/App/Branding.cpp                               |   2 +-
 src/Base/FileInfo.h                                |   6 +-
 src/Base/Quantity.h                                |   3 +
 src/Base/Tools2D.cpp                               |  18 ++--
 src/Base/UnitsApi.cpp                              |   2 +-
 src/Base/Uuid.cpp                                  |   6 +-
 src/Gui/Action.cpp                                 |  16 +--
 src/Gui/Application.cpp                            |  32 +++---
 src/Gui/BitmapFactory.cpp                          |  20 ++--
 src/Gui/BlenderNavigationStyle.cpp                 |  58 +++++------
 src/Gui/CADNavigationStyle.cpp                     |  66 ++++++------
 src/Gui/CallTips.cpp                               |  12 +--
 src/Gui/Command.cpp                                |   8 +-
 src/Gui/CommandDoc.cpp                             |  12 +--
 src/Gui/CommandStd.cpp                             |   6 +-
 src/Gui/CommandTest.cpp                            |   4 +-
 src/Gui/CommandView.cpp                            |  42 ++++----
 src/Gui/DemoMode.cpp                               |   2 +-
 src/Gui/DemoMode.h                                 |   2 +-
 src/Gui/DlgActionsImp.cpp                          |  20 ++--
 src/Gui/DlgActivateWindowImp.cpp                   |   4 +-
 src/Gui/DlgActivateWindowImp.h                     |   2 +-
 src/Gui/DlgCommandsImp.cpp                         |   4 +-
 src/Gui/DlgCustomizeImp.cpp                        |   4 +-
 src/Gui/DlgCustomizeImp.h                          |   2 +-
 src/Gui/DlgCustomizeSpaceball.cpp                  |  22 ++--
 src/Gui/DlgDisplayPropertiesImp.cpp                |  10 +-
 src/Gui/DlgDisplayPropertiesImp.h                  |   2 +-
 src/Gui/DlgEditFileIncludeProptertyExternal.cpp    |   4 +-
 src/Gui/DlgEditFileIncludeProptertyExternal.h      |   2 +-
 src/Gui/DlgEditorImp.cpp                           |  46 ++++----
 src/Gui/DlgGeneralImp.cpp                          |  22 ++--
 src/Gui/DlgInputDialogImp.cpp                      |   4 +-
 src/Gui/DlgInputDialogImp.h                        |   2 +-
 src/Gui/DlgKeyboardImp.cpp                         |  23 ++--
 src/Gui/DlgMacroExecuteImp.cpp                     |   8 +-
 src/Gui/DlgMacroExecuteImp.h                       |   2 +-
 src/Gui/DlgMacroRecordImp.cpp                      |   4 +-
 src/Gui/DlgMacroRecordImp.h                        |   2 +-
 src/Gui/DlgMaterialPropertiesImp.cpp               |   4 +-
 src/Gui/DlgMaterialPropertiesImp.h                 |   2 +-
 src/Gui/DlgOnlineHelpImp.cpp                       |   2 +-
 src/Gui/DlgParameterImp.cpp                        | 112 ++++++++++----------
 src/Gui/DlgParameterImp.h                          |   2 +-
 src/Gui/DlgPreferencesImp.cpp                      |   6 +-
 src/Gui/DlgPreferencesImp.h                        |   2 +-
 src/Gui/DlgProjectInformationImp.cpp               |  22 ++--
 src/Gui/DlgProjectInformationImp.h                 |   2 +-
 src/Gui/DlgProjectUtility.cpp                      |   2 +-
 src/Gui/DlgProjectUtility.h                        |   2 +-
 src/Gui/DlgPropertyLink.cpp                        |   2 +-
 src/Gui/DlgPropertyLink.h                          |   2 +-
 src/Gui/DlgReportViewImp.cpp                       |   2 +-
 src/Gui/DlgRunExternal.cpp                         |   4 +-
 src/Gui/DlgRunExternal.h                           |   2 +-
 src/Gui/DlgSettings3DViewImp.cpp                   |  14 +--
 src/Gui/DlgSettingsColorGradientImp.cpp            |   2 +-
 src/Gui/DlgSettingsColorGradientImp.h              |   2 +-
 src/Gui/DlgSettingsDocumentImp.cpp                 |  18 ++--
 src/Gui/DlgTipOfTheDayImp.cpp                      |  10 +-
 src/Gui/DlgTipOfTheDayImp.h                        |   2 +-
 src/Gui/DlgToolbarsImp.cpp                         |  36 +++----
 src/Gui/DlgUnitsCalculatorImp.cpp                  |   8 +-
 src/Gui/DlgUnitsCalculatorImp.h                    |   2 +-
 src/Gui/DlgWorkbenchesImp.cpp                      |  16 +--
 src/Gui/DockWindowManager.cpp                      |   6 +-
 src/Gui/Document.cpp                               |   6 +-
 src/Gui/DownloadDialog.cpp                         |   2 +-
 src/Gui/DownloadItem.cpp                           |   6 +-
 src/Gui/EditorView.cpp                             |   2 +-
 src/Gui/ExpressionBinding.cpp                      |   4 +-
 src/Gui/ExpressionCompleter.cpp                    |  10 +-
 src/Gui/FileDialog.cpp                             |  26 ++---
 src/Gui/FileDialog.h                               |   2 +-
 src/Gui/GestureNavigationStyle.cpp                 |  44 ++++----
 src/Gui/GraphvizView.cpp                           |  12 +--
 src/Gui/HelpView.cpp                               |  14 +--
 src/Gui/InputField.cpp                             |  20 ++--
 src/Gui/InputVector.cpp                            |   4 +-
 src/Gui/InputVector.h                              |  10 +-
 src/Gui/InventorNavigationStyle.cpp                |  58 +++++------
 src/Gui/Language/Translator.cpp                    |   6 +-
 src/Gui/MDIView.cpp                                |   4 +-
 src/Gui/MDIView.h                                  |   2 +-
 src/Gui/Macro.cpp                                  |  16 +--
 src/Gui/MainWindow.cpp                             |  98 ++++++++---------
 src/Gui/MainWindow.h                               |   2 +-
 src/Gui/ManualAlignment.cpp                        |   6 +-
 src/Gui/MayaGestureNavigationStyle.cpp             |  42 ++++----
 src/Gui/MenuManager.cpp                            |  18 ++--
 src/Gui/MouseSelection.cpp                         |   8 +-
 src/Gui/NavigationStyle.cpp                        |  64 ++++++------
 src/Gui/NetworkRetriever.cpp                       |  56 +++++-----
 src/Gui/OnlineDocumentation.cpp                    |  22 ++--
 src/Gui/OpenCascadeNavigationStyle.cpp             |  46 ++++----
 src/Gui/Placement.cpp                              |  16 +--
 src/Gui/Placement.h                                |   4 +-
 src/Gui/PrefWidgets.cpp                            |   2 +-
 src/Gui/ProgressBar.cpp                            |   2 +-
 src/Gui/PythonConsole.cpp                          |  28 ++---
 src/Gui/PythonConsolePy.cpp                        |   2 +-
 src/Gui/QListWidgetCustom.cpp                      |   4 +-
 src/Gui/QuantitySpinBox.cpp                        |   8 +-
 src/Gui/Quarter/ContextMenu.cpp                    |   2 +-
 src/Gui/Quarter/DragDropHandler.cpp                |   1 +
 src/Gui/Quarter/ImageReader.cpp                    |   4 +-
 src/Gui/Quarter/KeyboardP.cpp                      |   2 +-
 src/Gui/Quarter/QuarterWidget.cpp                  |   6 +-
 src/Gui/Quarter/QuarterWidget.h                    |   2 +-
 src/Gui/Quarter/QuarterWidgetP.cpp                 |   4 +-
 src/Gui/Quarter/SensorManager.cpp                  |   6 +-
 src/Gui/Quarter/SoQTQuarterAdaptor.cpp             |  28 ++---
 src/Gui/Quarter/SpaceNavigatorDevice.cpp           |   4 +-
 src/Gui/ReportView.cpp                             |   2 +-
 src/Gui/SceneInspector.cpp                         |   6 +-
 src/Gui/SceneInspector.h                           |   2 +-
 src/Gui/Selection.cpp                              |   8 +-
 src/Gui/SelectionView.cpp                          |  50 ++++-----
 src/Gui/SoAxisCrossKit.cpp                         |  28 ++---
 src/Gui/SoAxisCrossKit.h                           |   2 +-
 src/Gui/SoFCBoundingBox.cpp                        |   4 +-
 src/Gui/SoFCDB.cpp                                 |   6 +-
 src/Gui/SoFCInteractiveElement.cpp                 |   4 +-
 src/Gui/SoFCOffscreenRenderer.cpp                  |  12 +--
 src/Gui/SoFCSelection.cpp                          |  58 +++++------
 src/Gui/SoFCSelectionAction.cpp                    |  14 +--
 src/Gui/SoFCSelectionAction.h                      |   2 +-
 src/Gui/SoFCUnifiedSelection.cpp                   |  20 ++--
 src/Gui/SoNavigationDragger.cpp                    |  56 +++++-----
 src/Gui/SoNavigationDragger.h                      |   2 +-
 src/Gui/SoTextLabel.cpp                            |  16 +--
 src/Gui/SpinBox.cpp                                |  30 +++---
 src/Gui/Splashscreen.cpp                           |  92 ++++++++--------
 src/Gui/Splashscreen.h                             |   2 +-
 src/Gui/SplitView3DInventor.cpp                    |  12 +--
 src/Gui/SplitView3DInventor.h                      |   4 +-
 src/Gui/TaskView/TaskAppearance.cpp                |   6 +-
 src/Gui/TaskView/TaskSelectLinkProperty.cpp        |   2 +-
 src/Gui/TextEdit.cpp                               |   6 +-
 src/Gui/TextureMapping.cpp                         |   4 +-
 src/Gui/TextureMapping.h                           |   2 +-
 src/Gui/Thumbnail.cpp                              |   2 +-
 src/Gui/ToolBarManager.cpp                         |   4 +-
 src/Gui/ToolBox.cpp                                |   4 +-
 src/Gui/ToolBoxManager.cpp                         |   2 +-
 src/Gui/TouchpadNavigationStyle.cpp                |  52 ++++-----
 src/Gui/Transform.cpp                              |   2 +-
 src/Gui/Transform.h                                |   2 +-
 src/Gui/Tree.cpp                                   |  14 +--
 src/Gui/View3DInventor.cpp                         |  10 +-
 src/Gui/View3DInventor.h                           |   2 +-
 src/Gui/View3DInventorExamples.cpp                 |   4 +-
 src/Gui/View3DInventorViewer.cpp                   |  20 ++--
 src/Gui/View3DInventorViewer.h                     |   2 +-
 src/Gui/ViewProvider.cpp                           |   4 +-
 src/Gui/ViewProviderAnnotation.cpp                 |   6 +-
 src/Gui/ViewProviderGeometryObject.cpp             |   8 +-
 src/Gui/WidgetFactory.cpp                          |  32 +++---
 src/Gui/Widgets.cpp                                |  14 +--
 src/Gui/Widgets.h                                  |   4 +-
 src/Gui/Workbench.cpp                              |   2 +-
 src/Gui/propertyeditor/PropertyItem.cpp            | 116 ++++++++++-----------
 src/Gui/propertyeditor/PropertyItem.h              |   5 +-
 src/Gui/propertyeditor/PropertyModel.cpp           |  15 +--
 src/Main/FreeCADGuiPy.cpp                          |   4 +-
 src/Main/MainGui.cpp                               |  16 +--
 src/Main/MainPy.cpp                                |   2 +-
 src/Mod/Complete/Gui/Workbench.h                   |   2 +-
 src/Mod/Drawing/Gui/Command.cpp                    |  10 +-
 src/Mod/Fem/Gui/TaskFemConstraint.cpp              |   2 +-
 src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp       |   2 +-
 src/Mod/Fem/Gui/TaskFemConstraintForce.cpp         |   2 +-
 src/Mod/Fem/Gui/TaskFemConstraintGear.cpp          |   2 +-
 src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp      |   2 +-
 src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp        |   2 +-
 src/Mod/Fem/Gui/TaskObjectName.cpp                 |   2 +-
 src/Mod/Image/Gui/GLImageBox.cpp                   |   2 +-
 src/Mod/Image/Gui/GLImageBox.h                     |   2 +-
 src/Mod/Image/Gui/ImageView.cpp                    |  20 ++--
 src/Mod/Import/Gui/AppImportGuiPy.cpp              |  10 +-
 src/Mod/Inspection/Gui/ViewProviderInspection.cpp  |   2 +-
 src/Mod/Inspection/Gui/VisualInspection.cpp        |  16 +--
 src/Mod/Inspection/Gui/VisualInspection.h          |   2 +-
 src/Mod/Mesh/App/Core/Grid.h                       |   2 +-
 src/Mod/Mesh/App/Core/Helpers.h                    |  10 +-
 src/Mod/Mesh/App/Core/MeshIO.cpp                   |   4 +-
 src/Mod/Mesh/App/Core/tritritest.h                 |  14 +--
 src/Mod/Mesh/App/WildMagic4/Wm4LinearSystem.h      |  12 +--
 src/Mod/Mesh/Gui/Command.cpp                       |   6 +-
 src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp            |  22 ++--
 src/Mod/Mesh/Gui/DlgEvaluateMeshImp.h              |   4 +-
 src/Mod/Mesh/Gui/DlgRegularSolidImp.cpp            |   8 +-
 src/Mod/Mesh/Gui/DlgRegularSolidImp.h              |   4 +-
 src/Mod/Mesh/Gui/DlgSmoothing.cpp                  |   2 +-
 src/Mod/Mesh/Gui/DlgSmoothing.h                    |   2 +-
 src/Mod/Mesh/Gui/RemoveComponents.cpp              |   4 +-
 src/Mod/Mesh/Gui/RemoveComponents.h                |   4 +-
 src/Mod/Mesh/Gui/Segmentation.cpp                  |   2 +-
 src/Mod/Mesh/Gui/Segmentation.h                    |   2 +-
 src/Mod/Mesh/Gui/SoFCIndexedFaceSet.cpp            |  22 ++--
 src/Mod/Mesh/Gui/SoFCMeshObject.cpp                |  38 +++----
 src/Mod/Mesh/Gui/SoPolygon.cpp                     |   6 +-
 src/Mod/Mesh/Gui/ViewProviderCurvature.cpp         |   6 +-
 src/Mod/Mesh/Gui/Workbench.cpp                     |  24 ++---
 src/Mod/MeshPart/App/MeshAlgos.cpp                 |  20 ++--
 src/Mod/MeshPart/Gui/Tessellation.cpp              |  14 +--
 src/Mod/Part/Gui/Command.cpp                       |  34 +++---
 src/Mod/Part/Gui/CommandParametric.cpp             |  10 +-
 src/Mod/Part/Gui/CrossSections.cpp                 |  14 +--
 src/Mod/Part/Gui/CrossSections.h                   |   2 +-
 src/Mod/Part/Gui/DlgBooleanOperation.cpp           |   4 +-
 src/Mod/Part/Gui/DlgExtrusion.cpp                  |  30 +++---
 src/Mod/Part/Gui/DlgExtrusion.h                    |   2 +-
 src/Mod/Part/Gui/DlgFilletEdges.cpp                |  46 ++++----
 src/Mod/Part/Gui/DlgFilletEdges.h                  |   6 +-
 src/Mod/Part/Gui/DlgPartBoxImp.cpp                 |   4 +-
 src/Mod/Part/Gui/DlgPartBoxImp.h                   |   2 +-
 src/Mod/Part/Gui/DlgPartCylinderImp.cpp            |   4 +-
 src/Mod/Part/Gui/DlgPartCylinderImp.h              |   2 +-
 src/Mod/Part/Gui/DlgPartImportIgesImp.cpp          |   4 +-
 src/Mod/Part/Gui/DlgPartImportIgesImp.h            |   2 +-
 src/Mod/Part/Gui/DlgPartImportStepImp.cpp          |   4 +-
 src/Mod/Part/Gui/DlgPartImportStepImp.h            |   2 +-
 src/Mod/Part/Gui/DlgPrimitives.cpp                 |  74 ++++++-------
 src/Mod/Part/Gui/DlgRevolution.cpp                 |  20 ++--
 src/Mod/Part/Gui/DlgRevolution.h                   |   2 +-
 src/Mod/Part/Gui/Mirroring.cpp                     |  16 +--
 src/Mod/Part/Gui/SoBrepEdgeSet.cpp                 |  12 +--
 src/Mod/Part/Gui/SoBrepFaceSet.cpp                 |  44 ++++----
 src/Mod/Part/Gui/SoBrepPointSet.cpp                |  12 +--
 src/Mod/Part/Gui/SoFCShapeObject.cpp               |   2 +-
 src/Mod/Part/Gui/TaskCheckGeometry.cpp             |   6 +-
 src/Mod/Part/Gui/TaskDimension.cpp                 |  40 +++----
 src/Mod/Part/Gui/TaskFaceColors.cpp                |  12 +--
 src/Mod/Part/Gui/TaskLoft.cpp                      |  22 ++--
 src/Mod/Part/Gui/TaskOffset.cpp                    |   2 +-
 src/Mod/Part/Gui/TaskShapeBuilder.cpp              |  24 ++---
 src/Mod/Part/Gui/TaskSweep.cpp                     |  18 ++--
 src/Mod/Part/Gui/TaskThickness.cpp                 |   2 +-
 src/Mod/Part/Gui/ViewProviderCurveNet.cpp          |   2 +-
 src/Mod/Part/Gui/ViewProviderMirror.cpp            |   2 +-
 src/Mod/PartDesign/Gui/FeaturePickDialog.cpp       |   4 +-
 src/Mod/PartDesign/Gui/TaskDraftParameters.cpp     |   2 +-
 src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp    |   4 +-
 .../PartDesign/Gui/TaskLinearPatternParameters.cpp |  12 +--
 src/Mod/PartDesign/Gui/TaskMirroredParameters.cpp  |  12 +--
 .../Gui/TaskMultiTransformParameters.cpp           |  12 +--
 src/Mod/PartDesign/Gui/TaskPadParameters.cpp       |   2 +-
 src/Mod/PartDesign/Gui/TaskPocketParameters.cpp    |   2 +-
 .../PartDesign/Gui/TaskPolarPatternParameters.cpp  |  10 +-
 .../PartDesign/Gui/TaskRevolutionParameters.cpp    |   2 +-
 src/Mod/PartDesign/Gui/TaskScaledParameters.cpp    |   6 +-
 .../PartDesign/Gui/TaskTransformedParameters.cpp   |   4 +-
 src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp |   2 +-
 src/Mod/Path/Gui/AppPathGuiPy.cpp                  |  18 ++--
 src/Mod/Path/Gui/TaskDlgPathCompound.cpp           |   8 +-
 src/Mod/Path/libarea/kurve/Finite.cpp              |   2 +-
 src/Mod/Points/Gui/DlgPointsReadImp.cpp            |   2 +-
 src/Mod/Points/Gui/DlgPointsReadImp.h              |   2 +-
 src/Mod/Raytracing/Gui/Command.cpp                 |   4 +-
 src/Mod/Raytracing/Gui/ViewProvider.cpp            |   8 +-
 .../ReverseEngineering/Gui/FitBSplineSurface.cpp   |   2 +-
 src/Mod/ReverseEngineering/Gui/Poisson.cpp         |   2 +-
 src/Mod/Robot/Gui/CommandTrajectory.cpp            |  12 +--
 src/Mod/Robot/Gui/TaskEdge2TracParameter.cpp       |   4 +-
 src/Mod/Robot/Gui/TaskRobot6Axis.cpp               |   4 +-
 src/Mod/Robot/Gui/TaskTrajectory.cpp               |  16 +--
 .../Robot/Gui/TaskTrajectoryDressUpParameter.cpp   |   2 +-
 src/Mod/Robot/Gui/TrajectorySimulate.cpp           |  14 +--
 src/Mod/Robot/Gui/ViewProviderRobotObject.cpp      |  12 +--
 src/Mod/Robot/Gui/Workbench.cpp                    |   6 +-
 src/Mod/Sketcher/Gui/CommandCreateGeo.cpp          |   2 +-
 src/Mod/Sketcher/Gui/CommandSketcherTools.cpp      |   4 +-
 src/Mod/Sketcher/Gui/DrawSketchHandler.cpp         |  12 +--
 src/Mod/Sketcher/Gui/SoDatumLabel.cpp              |   2 +-
 src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp    |  12 +--
 src/Mod/Sketcher/Gui/TaskSketcherElements.cpp      |   6 +-
 src/Mod/Sketcher/Gui/ViewProviderSketch.cpp        |  50 ++++-----
 src/Mod/Spreadsheet/Gui/AppSpreadsheetGui.cpp      |   5 +
 src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp        |   4 +-
 .../Spreadsheet/Gui/ViewProviderSpreadsheet.cpp    |   2 +-
 src/Mod/Spreadsheet/Gui/Workbench.cpp              |  10 +-
 src/Mod/Spreadsheet/Gui/qtcolorpicker.cpp          |  22 ++--
 src/Mod/Spreadsheet/Gui/qtcolorpicker.h            |   4 +-
 src/Mod/Test/Gui/UnitTestImp.cpp                   |   6 +-
 src/Mod/Test/Gui/UnitTestImp.h                     |   2 +-
 src/Mod/Test/Gui/UnitTestPy.cpp                    |   2 +-
 src/Mod/Web/Gui/AppWebGuiPy.cpp                    |   2 +-
 src/Mod/Web/Gui/BrowserView.h                      |   2 +-
 290 files changed, 1741 insertions(+), 1725 deletions(-)
 
Cheers,
Mateusz
wmayer
Site Admin
Posts: 15483
Joined: Thu Feb 19, 2009 10:32 am

Re: Qt4/Qt5 neutral compilation fixes

Postby wmayer » Tue Jan 05, 2016 2:42 pm

QObject::accessibleName() is not available in Qt5. Replace it with objectName().
Are you sure that this method doesn't exist in Qt5? When looking at the Qt5 docs this method is still listed: http://doc.qt.io/qt-5/qwidget.html#accessibleName-prop
Make Base::Quantity known to QMetaType.
Can you explain why this is needed, please?
wmayer
Site Admin
Posts: 15483
Joined: Thu Feb 19, 2009 10:32 am

Re: Qt4/Qt5 neutral compilation fixes

Postby wmayer » Tue Jan 05, 2016 4:23 pm

The following commits are merged:
QString::toAscii() is obsolete in Qt5. Replace it with toLatin1().
QString::fromAscii() is obsolete in Qt5. Replace it with fromLatin1().
Qt::WFlags is obsolete in Qt5. Replace it with Qt::WindowFlags.
Qt4's qglobal.h defined TRUE and FALSE. Qt5 does not do it anymore. Replace it with true and false.
QKeySequence::operator QString() is obsolete in Qt5. Use toString(QKeySequence::NativeText) instead.
QAbstractItemModel::reset() is obsolete in Qt5. Use beginResetModel() and endResetModel() instead.
Change includes in Quarter to be compatible with Qt5.
Change includes in Spreadsheet to be compatible with Qt5.

Waiting for comments on:
QObject::accessibleName() is not available in Qt5. Replace it with objectName().
Make Base::Quantity known to QMetaType.

Thanks for your great work so far!
User avatar
f3nix
Posts: 330
Joined: Sat May 30, 2015 11:58 am

Re: Qt4/Qt5 neutral compilation fixes

Postby f3nix » Tue Jan 05, 2016 11:31 pm

Hi!
wmayer wrote:The following commits are merged:
QString::toAscii() is obsolete in Qt5. Replace it with toLatin1().
QString::fromAscii() is obsolete in Qt5. Replace it with fromLatin1().
Qt::WFlags is obsolete in Qt5. Replace it with Qt::WindowFlags.
Qt4's qglobal.h defined TRUE and FALSE. Qt5 does not do it anymore. Replace it with true and false.
QKeySequence::operator QString() is obsolete in Qt5. Use toString(QKeySequence::NativeText) instead.
QAbstractItemModel::reset() is obsolete in Qt5. Use beginResetModel() and endResetModel() instead.
Change includes in Quarter to be compatible with Qt5.
Change includes in Spreadsheet to be compatible with Qt5.
Thank you! :)
wmayer wrote:
QObject::accessibleName() is not available in Qt5. Replace it with objectName().
Are you sure that this method doesn't exist in Qt5? When looking at the Qt5 docs this method is still listed: http://doc.qt.io/qt-5/qwidget.html#accessibleName-prop
It fixes this build error with Qt5:

Code: Select all

[ 13%] Building CXX object src/Gui/CMakeFiles/FreeCADGui.dir/QListWidgetCustom.cpp.o
/home/f3nix/devel/freecad/my_freecad_qt5/FreeCAD/src/Gui/QListWidgetCustom.cpp: In member function ‘virtual void QListWidgetCustom::dragMoveEvent(QDragMoveEvent*)’:
/home/f3nix/devel/freecad/my_freecad_qt5/FreeCAD/src/Gui/QListWidgetCustom.cpp:50:26: error: ‘class QObject’ has no member named ‘accessibleName’
         if (e->source()->accessibleName() == disabled_wbs) {
                          ^
src/Gui/CMakeFiles/FreeCADGui.dir/build.make:3076: polecenia dla obiektu 'src/Gui/CMakeFiles/FreeCADGui.dir/QListWidgetCustom.cpp.o' nie powiodły się
make[2]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/QListWidgetCustom.cpp.o] Błąd 1
CMakeFiles/Makefile2:4637: polecenia dla obiektu 'src/Gui/CMakeFiles/FreeCADGui.dir/all' nie powiodły się
make[1]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/all] Błąd 2
Makefile:127: polecenia dla obiektu 'all' nie powiodły się
make: *** [all] Błąd 2
Maybe there is some better fix for it?

As far as I can tell it is only used for drag and drop support for enabling/disabling workbenches. And it needs some more love.
I can do something like this with current implementation:
dragging_problem.png
dragging_problem.png (163.56 KiB) Viewed 2962 times
wmayer wrote:
Make Base::Quantity known to QMetaType.
Can you explain why this is needed, please?
With Qt5 and first compilation I got:

Code: Select all

[ 13%] Building CXX object src/Gui/CMakeFiles/FreeCADGui.dir/DlgUnitsCalculatorImp.cpp.o
In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/qcoreapplication.h:37:0,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qapplication.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QApplication:1,
                 from /home/f3nix/devel/freecad/my_freecad_qt5/FreeCAD/src/Gui/DlgUnitsCalculatorImp.cpp:26:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qmetatype.h: In instantiation of ‘int qMetaTypeId() [with T = Base::Quantity]’:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qmetatype.h:1732:26:   required from ‘int qRegisterMetaType() [with T = Base::Quantity]’
/home/f3nix/devel/freecad/my_freecad_qt5/FreeCAD/build-test/src/Gui/moc_DlgUnitsCalculatorImp.cpp:104:86:   required from here
/usr/include/x86_64-linux-gnu/qt5/QtCore/qmetatype.h:1725:5: error: invalid application of ‘sizeof’ to incomplete type ‘QStaticAssertFailure<false>’
     Q_STATIC_ASSERT_X(QMetaTypeId2<T>::Defined, "Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system");
     ^
src/Gui/CMakeFiles/FreeCADGui.dir/build.make:2260: polecenia dla obiektu 'src/Gui/CMakeFiles/FreeCADGui.dir/DlgUnitsCalculatorImp.cpp.o' nie powiodły się
make[2]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/DlgUnitsCalculatorImp.cpp.o] Błąd 1
CMakeFiles/Makefile2:4637: polecenia dla obiektu 'src/Gui/CMakeFiles/FreeCADGui.dir/all' nie powiodły się
make[1]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/all] Błąd 2
Makefile:127: polecenia dla obiektu 'all' nie powiodły się
make: *** [all] Błąd 2
After applying changes to: src/Base/Quantity.h only (https://github.com/f3nix/FreeCAD/commit ... cbfe63aa43)

Code: Select all

[ 13%] Building CXX object src/Gui/CMakeFiles/FreeCADGui.dir/CommandDoc.cpp.o
In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/qobject.h:48:0,
                 from /usr/include/x86_64-linux-gnu/qt5/QtCore/qcoreapplication.h:40,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qapplication.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QApplication:1,
                 from /home/f3nix/devel/freecad/my_freecad_qt5/FreeCAD/src/Gui/CommandDoc.cpp:26:
/home/f3nix/devel/freecad/my_freecad_qt5/FreeCAD/src/Gui/propertyeditor/PropertyItem.h:46:1: error: redefinition of ‘struct QMetaTypeId<Base::Quantity>’
 Q_DECLARE_METATYPE(Base::Quantity)
 ^
/home/f3nix/devel/freecad/my_freecad_qt5/FreeCAD/src/Base/Quantity.h:193:1: error: previous definition of ‘struct QMetaTypeId<Base::Quantity>’
 Q_DECLARE_METATYPE(Base::Quantity)
 ^
src/Gui/CMakeFiles/FreeCADGui.dir/build.make:2020: polecenia dla obiektu 'src/Gui/CMakeFiles/FreeCADGui.dir/CommandDoc.cpp.o' nie powiodły się
make[2]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/CommandDoc.cpp.o] Błąd 1
CMakeFiles/Makefile2:4637: polecenia dla obiektu 'src/Gui/CMakeFiles/FreeCADGui.dir/all' nie powiodły się
make[1]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/all] Błąd 2
Makefile:127: polecenia dla obiektu 'all' nie powiodły się
make: *** [all] Błąd 2
Commenting out Q_DECLARE_METATYPE(Base::Quantity) in PropertyItem.h fixed it for Qt5.

But for Qt4:

Code: Select all

[ 19%] Building CXX object src/Gui/CMakeFiles/FreeCADGui.dir/propertyeditor/PropertyItem.cpp.o
In file included from /home/f3nix/devel/freecad/my_freecad_qt5/FreeCAD/src/Gui/propertyeditor/PropertyItem.cpp:2603:0:
/home/f3nix/devel/freecad/my_freecad_qt5/FreeCAD/build-test-qt4/src/Gui/propertyeditor/moc_PropertyItem.cpp:222:10: error: ‘staticMetaObject’ is not a member of ‘Base’
         &Base::staticMetaObject,
          ^
/home/f3nix/devel/freecad/my_freecad_qt5/FreeCAD/build-test-qt4/src/Gui/propertyeditor/moc_PropertyItem.cpp:547:10: error: ‘staticMetaObject’ is not a member of ‘Base’
         &Base::staticMetaObject,
          ^
src/Gui/CMakeFiles/FreeCADGui.dir/build.make:4441: polecenia dla obiektu 'src/Gui/CMakeFiles/FreeCADGui.dir/propertyeditor/PropertyItem.cpp.o' nie powiodły się
make[2]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/propertyeditor/PropertyItem.cpp.o] Błąd 1
CMakeFiles/Makefile2:4487: polecenia dla obiektu 'src/Gui/CMakeFiles/FreeCADGui.dir/all' nie powiodły się
make[1]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/all] Błąd 2
Makefile:127: polecenia dla obiektu 'all' nie powiodły się
make: *** [all] Błąd 2
So I have applied the second change to src/Gui/propertyeditor/PropertyItem.h.

Cheers,
Mateusz

UPDATE:
Qt4: QDragMoveEvent source() const : QWidget *
Qt5: QDragMoveEvent source() const : QObject *

So this change is Qt5 specific.
wmayer
Site Admin
Posts: 15483
Joined: Thu Feb 19, 2009 10:32 am

Re: Qt4/Qt5 neutral compilation fixes

Postby wmayer » Wed Jan 06, 2016 4:04 pm

As far as I can tell it is only used for drag and drop support for enabling/disabling workbenches. And it needs some more love.
I can do something like this with current implementation:
I have fixed this. In git commit 0b3f60a68c6533 it is checked if the list view has defined a property "OnlyAcceptFrom". If not, it allows all drag and drop events, otherwise it checks if the name of the source object is part of the whitelist.
wmayer
Site Admin
Posts: 15483
Joined: Thu Feb 19, 2009 10:32 am

Re: Qt4/Qt5 neutral compilation fixes

Postby wmayer » Wed Jan 06, 2016 4:17 pm

With Qt5 and first compilation I got:...
Could you test if adding these lines to DlgUnitsCalculatorImp.h solves the problem, too?

Code: Select all

#include <Base/Quantity.h>
#include "ui_DlgUnitsCalculator.h"

#ifdef Q_MOC_RUN
Q_DECLARE_METATYPE(Base::Quantity)
#endif
For me the above works for Qt4.
User avatar
f3nix
Posts: 330
Joined: Sat May 30, 2015 11:58 am

Re: Qt4/Qt5 neutral compilation fixes

Postby f3nix » Wed Jan 06, 2016 11:02 pm

wmayer wrote:
With Qt5 and first compilation I got:...
Could you test if adding these lines to DlgUnitsCalculatorImp.h solves the problem, too?

Code: Select all

#include <Base/Quantity.h>
#include "ui_DlgUnitsCalculator.h"

#ifdef Q_MOC_RUN
Q_DECLARE_METATYPE(Base::Quantity)
#endif
For me the above works for Qt4.

Code: Select all

diff --git a/src/Gui/DlgUnitsCalculatorImp.h b/src/Gui/DlgUnitsCalculatorImp.h
index 6afbc66..6dc897d 100644
--- a/src/Gui/DlgUnitsCalculatorImp.h
+++ b/src/Gui/DlgUnitsCalculatorImp.h
@@ -24,11 +24,16 @@
 #ifndef GUI_DIALOG_DlgActivateWindowImp_H
 #define GUI_DIALOG_DlgActivateWindowImp_H
 
+#include <Base/Quantity.h>
 #include "ui_DlgUnitsCalculator.h"
 
 namespace Gui {
 namespace Dialog {
 
+#ifdef Q_MOC_RUN
+Q_DECLARE_METATYPE(Base::Quantity)
+#endif
+
 /**
  * The DlgUnitsCalculator provides a unit conversion dialog
  * \author Juergen Riegel 
Gives:

Code: Select all

[ 13%] Building CXX object src/Gui/CMakeFiles/FreeCADGui.dir/DlgUnitsCalculatorImp.cpp.o
In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/qcoreapplication.h:37:0,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/qapplication.h:37,
                 from /usr/include/x86_64-linux-gnu/qt5/QtWidgets/QApplication:1,
                 from /home/f3nix/devel/freecad/my_freecad_qt5/FreeCAD/src/Gui/DlgUnitsCalculatorImp.cpp:26:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qmetatype.h: In instantiation of ‘int qMetaTypeId() [with T = Base::Quantity]’:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qmetatype.h:1732:26:   required from ‘int qRegisterMetaType() [with T = Base::Quantity]’
/home/f3nix/devel/freecad/my_freecad_qt5/FreeCAD/build-qt5-debug/src/Gui/moc_DlgUnitsCalculatorImp.cpp:104:86:   required from here
/usr/include/x86_64-linux-gnu/qt5/QtCore/qmetatype.h:1725:5: error: invalid application of ‘sizeof’ to incomplete type ‘QStaticAssertFailure<false>’
     Q_STATIC_ASSERT_X(QMetaTypeId2<T>::Defined, "Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system");
     ^
src/Gui/CMakeFiles/FreeCADGui.dir/build.make:2260: polecenia dla obiektu 'src/Gui/CMakeFiles/FreeCADGui.dir/DlgUnitsCalculatorImp.cpp.o' nie powiodły się
make[2]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/DlgUnitsCalculatorImp.cpp.o] Błąd 1
CMakeFiles/Makefile2:4639: polecenia dla obiektu 'src/Gui/CMakeFiles/FreeCADGui.dir/all' nie powiodły się
make[1]: *** [src/Gui/CMakeFiles/FreeCADGui.dir/all] Błąd 2
Makefile:127: polecenia dla obiektu 'all' nie powiodły się
make: *** [all] Błąd 2
Cheers,
Mateusz
User avatar
f3nix
Posts: 330
Joined: Sat May 30, 2015 11:58 am

Re: Qt4/Qt5 neutral compilation fixes

Postby f3nix » Thu Jan 07, 2016 5:37 am

wmayer wrote:
As far as I can tell it is only used for drag and drop support for enabling/disabling workbenches. And it needs some more love.
I can do something like this with current implementation:
I have fixed this. In git commit 0b3f60a68c6533 it is checked if the list view has defined a property "OnlyAcceptFrom". If not, it allows all drag and drop events, otherwise it checks if the name of the source object is part of the whitelist.
Neat solution!
Works great both with Qt4 and Qt5. Thanks.

Cheers,
Mateusz
User avatar
f3nix
Posts: 330
Joined: Sat May 30, 2015 11:58 am

Re: Qt4/Qt5 neutral compilation fixes

Postby f3nix » Thu Jan 07, 2016 5:55 am

Here is the latest branch rebased on current master:

https://github.com/f3nix/FreeCAD/tree/qt5-transition-2

This version compiles and links under LInux (Qt4/Qt5). Windows version needs some more changes which I have not pushed yet.

It may be built without PySide2 (but then it does not start):
- comment out stuff Regarding PySide2 from main CMakeLists.txt
- # ifdef HAVE_PYSIDE from src/Gui/WidgetFactory.cpp needs to be commented out as well

This is not totally accurate since I'm writing it from my head. Will write something more this evening.

Usage:

Code: Select all

$ cmake -DCMAKE_BUILD_TYPE=Debug -DFREECAD_USE_QT=1 ..    // this is for Qt5 
                                            ^^^^
                               (@2014 by peterl94) :)
$ cmake -DCMAKE_BUILD_TYPE=Debug ..    // this is for Qt4
Cheers,
Mateusz
wmayer
Site Admin
Posts: 15483
Joined: Thu Feb 19, 2009 10:32 am

Re: Qt4/Qt5 neutral compilation fixes

Postby wmayer » Thu Jan 07, 2016 11:15 am

Here is the latest branch rebased on current master:
What else must be done for the Qt5 port other than that? Maybe we should leave the current master as is and do the complete porting to Qt5 in a separate branch (e.g. yours) but remove all old Qt4 stuff. What do you think?