Skip to content

Commit d8acc55

Browse files
3nidsm-kuhn
authored andcommitted
Fix Qt5 build for custom widgets
1 parent 664efe9 commit d8acc55

File tree

6 files changed

+41
-23
lines changed

6 files changed

+41
-23
lines changed

CMakeLists.txt

-6
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,7 @@ IF (ENABLE_QT5)
240240
FIND_PACKAGE(Qt5Script REQUIRED)
241241
FIND_PACKAGE(Qt5Sql REQUIRED)
242242
SET(QT5_BUILD TRUE)
243-
244243
INCLUDE("cmake/modules/ECMQt4To5Porting.cmake")
245-
246244
MESSAGE(STATUS "Found Qt version: ${Qt5Core_VERSION_STRING}")
247245
ELSE()
248246
FIND_PACKAGE(Qt4 ${QT_MIN_VERSION} REQUIRED)
@@ -251,10 +249,6 @@ ELSE()
251249
SET(QT_USE_QTSVG 1)
252250
SET(QT_USE_QTSQL 1)
253251
SET(QT_USE_QTWEBKIT 1)
254-
IF (WITH_CUSTOM_WIDGETS)
255-
SET(QT_USE_QTDESIGNER 1)
256-
ENDIF (WITH_CUSTOM_WIDGETS)
257-
258252
IF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR NOT QT_QTWEBKIT_FOUND OR (WITH_CUSTOM_WIDGETS AND NOT QT_QTDESIGNER_FOUND))
259253
MESSAGE(SEND_ERROR "Some Qt4 modules haven't been found!")
260254
ENDIF (NOT QT_QTXML_FOUND OR NOT QT_QTNETWORK_FOUND OR NOT QT_QTSVG_FOUND OR NOT QT_QTSQL_FOUND OR NOT QT_QTWEBKIT_FOUND OR (WITH_CUSTOM_WIDGETS AND NOT QT_QTDESIGNER_FOUND))

cmake/modules/ECMQt4To5Porting.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,6 @@ macro(qt4_add_resources)
243243
qt5_add_resources(${ARGN})
244244
endmacro()
245245

246+
# get the Qt plugins directory
247+
GET_TARGET_PROPERTY(QMAKE_EXECUTABLE Qt5::qmake LOCATION)
248+
EXEC_PROGRAM(${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_PLUGINS" RETURN_VALUE return_code OUTPUT_VARIABLE QT_PLUGINS_DIR )

src/customwidgets/CMakeLists.txt

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ ADD_DEFINITIONS(-DQT_PLUGIN)
22
ADD_DEFINITIONS(-DQT_NO_DEBUG)
33
ADD_DEFINITIONS(-DQT_SHARED)
44

5+
IF (QT5_BUILD)
6+
FIND_PACKAGE(Qt5Designer REQUIRED)
7+
ENDIF (QT5_BUILD)
8+
9+
SET(QT_USE_QTDESIGNER ON)
10+
511
IF (WIN32)
612
IF (MSVC)
713
ADD_DEFINITIONS("-DCUSTOMWIDGETS_EXPORT=${DLLEXPORT}")
@@ -51,8 +57,6 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
5157
qgsspinboxplugin.h
5258
)
5359

54-
QT4_WRAP_CPP(QGIS_CUSTOMWIDGETS_MOC_SRCS ${QGIS_CUSTOMWIDGETS_MOC_HDRS})
55-
5660
IF(MSVC)
5761
SET_SOURCE_FILES_PROPERTIES(${QGIS_CUSTOMWIDGETS_MOC_SRCS} PROPERTIES COMPILE_FLAGS "/wd4996" )
5862
ELSE(MSVC)
@@ -92,8 +96,11 @@ INCLUDE_DIRECTORIES(
9296
${CMAKE_CURRENT_SOURCE_DIR}/../gui/editorwidgets/
9397
${CMAKE_CURRENT_BINARY_DIR}/../ui/
9498
${GEOS_INCLUDE_DIR}
99+
${Qt5Designer_INCLUDE_DIRS}
95100
)
96101

102+
QT4_WRAP_CPP(QGIS_CUSTOMWIDGETS_MOC_SRCS ${QGIS_CUSTOMWIDGETS_MOC_HDRS})
103+
97104
#############################################################
98105
# qgis_customwidgets library
99106

src/customwidgets/qgiscustomwidgets.cpp

+19-15
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "qgsdoublespinboxplugin.h"
2626
#include "qgsfieldcomboboxplugin.h"
2727
#include "qgsfieldexpressionwidgetplugin.h"
28+
#include "qgsfilterlineeditplugin.h"
2829
#include "qgsmaplayercomboboxplugin.h"
2930
#include "qgsprojectionselectionwidgetplugin.h"
3031
#include "qgsrelationeditorwidgetplugin.h"
@@ -36,25 +37,28 @@
3637
QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
3738
: QObject( parent )
3839
{
39-
mWidgets.append( new QgsCollapsibleGroupBoxPlugin );
40-
mWidgets.append( new QgsColorButtonPlugin );
41-
mWidgets.append( new QgsColorButtonV2Plugin );
42-
mWidgets.append( new QgsDataDefinedButtonPlugin );
43-
mWidgets.append( new QgsDateTimeEditPlugin );
44-
mWidgets.append( new QgsDoubleSpinBoxPlugin );
45-
mWidgets.append( new QgsFieldComboBoxPlugin );
46-
mWidgets.append( new QgsFieldExpressionWidgetPlugin );
47-
mWidgets.append( new QgsMapLayerComboBoxPlugin );
48-
mWidgets.append( new QgsProjectionSelectionWidgetPlugin );
49-
mWidgets.append( new QgsRelationEditorWidgetPlugin );
50-
mWidgets.append( new QgsRelationReferenceWidgetPlugin );
51-
mWidgets.append( new QgsScaleRangeWidgetPlugin );
52-
mWidgets.append( new QgsSpinBoxPlugin );
40+
mWidgets.append( new QgsCollapsibleGroupBoxPlugin(this) );
41+
mWidgets.append( new QgsColorButtonPlugin(this) );
42+
mWidgets.append( new QgsColorButtonV2Plugin(this) );
43+
mWidgets.append( new QgsDataDefinedButtonPlugin(this) );
44+
mWidgets.append( new QgsDateTimeEditPlugin(this) );
45+
mWidgets.append( new QgsDoubleSpinBoxPlugin(this) );
46+
mWidgets.append( new QgsFieldComboBoxPlugin(this) );
47+
mWidgets.append( new QgsFieldExpressionWidgetPlugin(this) );
48+
mWidgets.append( new QgsFilterLineEditPlugin(this) );
49+
mWidgets.append( new QgsMapLayerComboBoxPlugin(this) );
50+
mWidgets.append( new QgsProjectionSelectionWidgetPlugin(this) );
51+
mWidgets.append( new QgsRelationEditorWidgetPlugin(this) );
52+
mWidgets.append( new QgsRelationReferenceWidgetPlugin(this) );
53+
mWidgets.append( new QgsScaleRangeWidgetPlugin(this) );
54+
mWidgets.append( new QgsSpinBoxPlugin(this) );
5355
}
5456

5557
QList<QDesignerCustomWidgetInterface*> QgisCustomWidgets::customWidgets() const
5658
{
5759
return mWidgets;
5860
}
5961

60-
Q_EXPORT_PLUGIN2( customwidgetsplugin, QgisCustomWidgets )
62+
#if QT_VERSION < 0x050000
63+
Q_EXPORT_PLUGIN2( customwidgetsplugin, QgisCustomWidgets )
64+
#endif

src/customwidgets/qgiscustomwidgets.h

+5
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@
1616
#ifndef QGISCUSTOMWIDGETS_H
1717
#define QGISCUSTOMWIDGETS_H
1818

19+
1920
#include <QDesignerCustomWidgetCollectionInterface>
2021
#include <qplugin.h>
2122

23+
2224
class QgisCustomWidgets : public QObject, public QDesignerCustomWidgetCollectionInterface
2325
{
2426
Q_OBJECT
27+
#if QT_VERSION >= 0x050000
28+
Q_PLUGIN_METADATA(IID "org.qgis.CustomWidgets")
29+
#endif
2530
Q_INTERFACES( QDesignerCustomWidgetCollectionInterface )
2631

2732
public:

src/providers/wms/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
IF (QT5_BUILD)
2+
FIND_PACKAGE(Qt5XmlPatterns REQUIRED)
3+
ENDIF()
4+
5+
16
SET (WMS_SRCS
27
qgswmscapabilities.cpp
38
qgswmsprovider.cpp

0 commit comments

Comments
 (0)