Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Qt5 support #1676

Closed
wants to merge 5 commits into from
Closed

Add Qt5 support #1676

wants to merge 5 commits into from

Conversation

m-kuhn
Copy link
Member

@m-kuhn m-kuhn commented Nov 7, 2014

Adds Qt5 support to QGIS.

To compile

Make sure you have the dependencies compiled and linked agains Qt5 also.
Most notably:

  • QWT
  • QWTPolar (or disable with -DWITH_QWTPOLAR=FALSE)
  • QScintilla2

Start with a clean build directory

cmake -DENABLE_QT5=TRUE -DWITH_BINDINGS=FALSE -DWITH_INTERNAL_QWTPOLAR=FALSE ../QGIS

You may have to adapt the paths to manually built Qt5 dependencies (as listed above)

make

TODO

Required

  • If ENABLE_QT5 is TRUE, Qt5 will be a hard requirement

Optional

  • Evis plugin is currently using QHttp. This class is no longer available in Qt5. Port this code to QNetworkAccessManager. Currently it's disabled for Qt5 builds.
  • Introduce black magic in CMake that finds PyQt5
  • Find a solution for QWTPolar that works for debian based distros. Possibilities:
    • Verify internal qwtpolar compatibility with Qt5 and update if appropriate
    • Build external packages for upstream (personal favorite)
    • Disable support for QWTPolar based features when external QWTPolar is unavailable

@wonder-sk
Copy link
Member

Looks good to me.

I would suggest that if ENABLE_QT5 is TRUE, Qt5 will be a hard requirement (and Qt4 will not be looked for). This should lower the chance of people wanting Qt5 build, but they end up with Qt4 build because of some configuration problems.

Why internal QWTPolar has to be disabled - can we make it compile with internal QWTPolar?

@m-kuhn
Copy link
Member Author

m-kuhn commented Nov 7, 2014

Hard requirement: Good idea.

INTERNAL_QWTPOLAR:
I never use it (it's in Fedora packages, so why not use the upstream one) and therefore cannot really comment.
I think that the version we provide in the sources is too old to be compiled against Qt5. But you can try if you like. If it would be for me, I'd remove this from the code, but there are probably packages/distros depending on this.

@wonder-sk
Copy link
Member

With qwtpolar, there is no debian/ubuntu package for qwtpolar - so having internal copy of it is quite convenient... we should just update the source if necessary.

@luca76
Copy link
Contributor

luca76 commented Nov 7, 2014

+1 for using internal qwtpolar. I was tired to compile always this package by hand....

@m-kuhn
Copy link
Member Author

m-kuhn commented Nov 7, 2014

Or create a package for these distros...
It's bloating the code for a feature that I guess nobody uses. Maybe we should replace it with a flag that allows to remove this feature instead.
But actually, I don't care enough to do something about it. Leaving the task of fixing this issue (in whatever way) to somebody else.

@m-kuhn
Copy link
Member Author

m-kuhn commented Nov 7, 2014

Updated original text with QWTPolar issue on the (optional) TODO list

@snorfalorpagus
Copy link
Contributor

Trying to configure this on OS X I get the following error:

 CMake Error at CMakeLists.txt:309 (INCLUDE):
   include called with wrong number of arguments.  include() only takes one
   file.

OS X 10.10, Qt 5.3.2, qwt 6.1.1, qwtpolar 1.1.0, qscintilla 2.8.

@m-kuhn
Copy link
Member Author

m-kuhn commented Nov 17, 2014

Thank you for reporting. Can you try again now?

@snorfalorpagus
Copy link
Contributor

@m-kuhn That seemed to fixed the configuration. Now it dies on make:

[ 34%] Building CXX object src/gui/CMakeFiles/qgis_gui.dir/qgsactionmenu.cpp.o
/Users/snorf/Desktop/QGIS/src/gui/qgsactionmenu.cpp:19:10: fatal error: 'QtGui/QMenuItem' file not found
#include <QtGui/QMenuItem>
         ^
1 error generated.
make[2]: *** [src/gui/CMakeFiles/qgis_gui.dir/qgsactionmenu.cpp.o] Error 1
make[1]: *** [src/gui/CMakeFiles/qgis_gui.dir/all] Error 2
make: *** [all] Error 2

Removal of the include allows the build to continue. I'm not sure if this needs to be excluded for Qt5, or if it can be removed in the Qt4 build also.
Next up is:

[ 88%] Generating ../output/i18n/qgis_ar.qm
/bin/sh: lrelease-qt5: command not found
make[2]: *** [output/i18n/qgis_ar.qm] Error 127
make[1]: *** [i18n/CMakeFiles/translations.dir/all] Error 2
make: *** [all] Error 2

Homebrew installs this as /usr/local/Cellar/qt5/5.3.2/bin/lrelease, so a symlink fixes that.
Now it dies on:

[ 93%] Built target qgis_coordinatereferencesystemtest_automoc
dyld: Library not loaded: libqscintilla2.11.dylib
  Referenced from: /Users/snorf/Desktop/QGIS/buildqt5/src/crssync/../../output/bin/crssync
  Reason: image not found
/bin/sh: line 1: 17598 Trace/BPT trap: 5       ../../output/bin/crssync
make[2]: *** [src/crssync/CMakeFiles/synccrsdb] Error 133
make[1]: *** [src/crssync/CMakeFiles/synccrsdb.dir/all] Error 2
make: *** [all] Error 2

I had to manually build Qscintilla2, as the one that comes with homebrew links to Qt4 not Qt5. I'm not sure what's going on here, as I've specified the path to the library in ccmake: /usr/local/Cellar/qt5/5.3.2/lib/libqscintilla2.dylib. A symlink as /usr/lib/libqscintilla2.11.dylib fixes this.

Now I'm stuck with a make install that doesn't work:

-- Updating QGIS library paths...
-- Copying Qt frameworks...
ditto: can't get real path for source '/imageformats/libqgif.dylib'
ditto: can't get real path for source '/imageformats/libqico.dylib'
ditto: can't get real path for source '/imageformats/libqjpeg.dylib'
ditto: can't get real path for source '/imageformats/libqsvg.dylib'
ditto: can't get real path for source '/imageformats/libqtiff.dylib'
ditto: can't get real path for source '/codecs/libqcncodecs.dylib'
ditto: can't get real path for source '/codecs/libqjpcodecs.dylib'
ditto: can't get real path for source '/codecs/libqkrcodecs.dylib'
ditto: can't get real path for source '/codecs/libqtwcodecs.dylib'
ditto: can't get real path for source '/iconengines/libqsvgicon.dylib'
ditto: can't get real path for source '/phonon_backend/libphonon_qt7.dylib'
-- Copying Qwt framework and updating library paths...
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: can't map file: /usr/local/lib/qwt.framework (Invalid argument)
-- Copying QScintilla2 library and updating library paths...
-- Copying PyQt...
ditto: can't get real path for source '/sip.so'
cp: directory /usr/local/QGIS.app/Contents/MacOS/../Resources/python does not exist
-- PyQt4 module Qt.so not found
-- PyQt4 module QtCore.so not found
-- PyQt4 module QtGui.so not found
-- PyQt4 module phonon.so not found
-- PyQt4 module QtXml.so not found
-- PyQt4 module QtNetwork.so not found
-- PyQt4 module QtScript.so not found
-- PyQt4 module QtSvg.so not found
-- PyQt4 module QtSql.so not found
-- PyQt4 module QtWebKit.so not found
-- PyQt4 module QtXmlPatterns.so not found
-- PyQt4 module QtDBus.so not found
-- PyQt4 module QtMultimedia.so not found
-- PyQt4 module QtOpenGL.so not found
-- PyQt4 module QtTest.so not found
cp: /PyQt/uic: No such file or directory
ditto: can't get real path for source '/pylupdate4'
ditto: can't get real path for source '/pyrcc4'
sed: /pyuic4: No such file or directory
-- Updating Qt library paths...

The resulting application crashes on startup with the following:

Crashed Thread:        0

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000002, 0x0000000000000000

Application Specific Information:
dyld: launch, loading dependent libraries

Dyld Error Message:
  Library not loaded: /usr/local/lib/QtSvg.framework/Versions/4/QtSvg
  Referenced from: /usr/local/lib/qwt.framework/Versions/6/qwt
  Reason: image not found

WITH_BINDINGS is OFF so I'm not sure why it's trying to do anything with PyQt4. Also, it should be looking for .dylib files not .so on OS X.

@m-kuhn
Copy link
Member Author

m-kuhn commented Nov 19, 2014

On 19.11.2014 01:00, Joshua Arnott wrote:

@m-kuhn https://github.com/m-kuhn That seemed to fixed the
configuration. Now it dies on make:

|[ 34%] Building CXX object src/gui/CMakeFiles/qgis_gui.dir/qgsactionmenu.cpp.o
/Users/snorf/Desktop/QGIS/src/gui/qgsactionmenu.cpp:19:10: fatal error: 'QtGui/QMenuItem' file not found
#include <QtGui/QMenuItem>
^
1 error generated.
make[2]: *** [src/gui/CMakeFiles/qgis_gui.dir/qgsactionmenu.cpp.o] Error 1
make[1]: *** [src/gui/CMakeFiles/qgis_gui.dir/all] Error 2
make: *** [all] Error 2|
|
|

Removal of the include allows the build to continue. I'm not sure if
this needs to be excluded for Qt5, or if it can be removed in the Qt4
build also.

Seems not to be required. Removed now.

Next up is:

|[ 88%] Generating ../output/i18n/qgis_ar.qm
/bin/sh: lrelease-qt5: command not found
make[2]: *** [output/i18n/qgis_ar.qm] Error 127
make[1]: *** [i18n/CMakeFiles/translations.dir/all] Error 2
make: *** [all] Error 2
|

Homebrew installs this as |/usr/local/Cellar/qt5/5.3.2/bin/lrelease|,
so a symlink fixes that.

I've seen that before on other platforms. I tried to change it in the
CMake files but that broke system where it is named lrelease-qt5.
I'm not sure how to handle this properly. Ideas welcome.

Now it dies on:

|[ 93%] Built target qgis_coordinatereferencesystemtest_automoc
dyld: Library not loaded: libqscintilla2.11.dylib
Referenced from: /Users/snorf/Desktop/QGIS/buildqt5/src/crssync/../../output/bin/crssync
Reason: image not found
/bin/sh: line 1: 17598 Trace/BPT trap: 5 ../../output/bin/crssync
make[2]: *** [src/crssync/CMakeFiles/synccrsdb] Error 133
make[1]: *** [src/crssync/CMakeFiles/synccrsdb.dir/all] Error 2
make: *** [all] Error 2
|

I had to manually build Qscintilla2, as the one that comes with
homebrew links to Qt4 not Qt5. I'm not sure what's going on here, as
I've specified the path to the library in ccmake:
|/usr/local/Cellar/qt5/5.3.2/lib/libqscintilla2.dylib|. Interesting
that it's looking for libqscintilla2.11.dylib not libqscintilla2.dylib?

Also not sure.
You could try

  • a clean rebuild
  • skim CMakeCache for any leftovers referencing qt4
  • set LD_LIBRARY_PATH so it will find the lib while building (never had
    to do that though...)

@m-kuhn
Copy link
Member Author

m-kuhn commented Nov 19, 2014

Did you disable WITH_BINDINGS?

@snorfalorpagus
Copy link
Contributor

@m-kuhn I think the issue is with qwt and qwtpolar still being linked to Qt4. Busy building them again now.

@snorfalorpagus
Copy link
Contributor

The rebuild of qwt and qwtpolar has fixed things. I can now build with QGIS_MACAPP_BUNDLE = 0.

screen shot 2014-11-19 at 14 06 24

I'm still having some issues with QGIS_PLUGIN_SUBDIR but I guess this is Mac specific and not related to Qt5.

The drag and drop of layers from Finder into the canvas doesn't work. It raises an error like this:

Invalid Data Source: /.file/id=6571367.9081392 is not a valid or recognized data source

@m-kuhn m-kuhn mentioned this pull request Nov 20, 2014
@snorfalorpagus
Copy link
Contributor

I've had a go at adding support for PyQt5. This includes the cmake "black magic". Commit is here, but I don't think it's ready for merge. Python is working (import PyQt5 works in qgspythonutilsimpl.cpp), but the qgis modules are broken.

snorfalorpagus@33e68e1

The approach I've taken is to remove the 4 prefix from a lot of the variables. For instance, PYUIC4_PROGRAM becomes PYUIC_PROGRAM. There are separate FindPyQt4.py and FindPyQt5.py scripts, as PyQt5 dropped support for the pyqtconfig module. Also FindSIP.py needed a slight tweak to point at the Qt5 sip files. Does this sound/look sensible?

The QXml module isn't supported in PyQt5, so some stuff will probably have to be modified to get the qgis modules to build. http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html

@m-kuhn
Copy link
Member Author

m-kuhn commented Nov 21, 2014

committed in 78c5195

@m-kuhn m-kuhn closed this Nov 21, 2014
@m-kuhn
Copy link
Member Author

m-kuhn commented Nov 21, 2014

@snorfalorpagus
I recently had a go and similar results (https://github.com/m-kuhn/QGIS/tree/pyqt5)
So I ended up postponing this for a general API break (Removal of QXml breaks too much of the API to be considered smooth)
Instead it should be possible to stay with PyQt4 for the moment.
Do you have another idea?

@m-kuhn m-kuhn deleted the qt5 branch November 21, 2014 13:21
@snorfalorpagus
Copy link
Contributor

It hadn't occured to me that it was possible to build PyQt4 against Qt5. If that is the case, why don't the Python bindings work?

You're right that dropping QXml would break too much.

@m-kuhn
Copy link
Member Author

m-kuhn commented Nov 24, 2014

Maybe they work. One would need to check with a custom pyqt4/qt5 build.

@m-kuhn
Copy link
Member Author

m-kuhn commented Dec 8, 2014

@m-kuhn
Copy link
Member Author

m-kuhn commented Jan 5, 2015

@snorfalorpagus QXml should be back...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants