This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Marble and Qt5

Tags: None
(comma "," separated)
dalishi
Registered Member
Posts
10
Karma
0

Marble and Qt5

Tue Jul 28, 2015 3:43 am
Dear All

Maybe the question is a old topic but I am eager to obtain a affirmative answer for it otherwise everyday searching google and cannot figure out which is the truth.

Basically, my story is to use marble widget with Qt to develop desktop software to display OSM maps. I have successfully compile and run marble with Qt4. Now I need to try with Qt5 for some reasons.

1. Is now the stable released marble support Qt5? If only a ongoing branch working on Qt5, where is it and how should I give it a try.

2. I have ldd the /usr/lib/libmarblewidget.so.18 and found which is still looking for qt4. So I checked the CMakeLists.txt in marble source and realized marble preferred to link Qt4 first and would try to link to Qt5 if Qt4 not found. So should I change the CMakeLists.txt to link to Qt5? Is this the right way?
Code: Select all
if(NOT QT5BUILD)
  find_package(Qt4)
endif()
if(QT4_FOUND)
  set( QT5BUILD FALSE )
  set( QT_USE_QTXML         ON )
  set( QT_USE_QTNETWORK     ON )
  set( QT_USE_QTTEST        ON )
  set( QT_USE_QTSCRIPT      ON )
  set( QT_USE_QTWEBKIT      ON )
  set( QT_USE_QTSVG         ON )
  set( QT_USE_QTDECLARATIVE ON )
  set( QT_USE_QTSQL         ON )
  set( QT_USE_QTDBUS        ON )
  include( ${QT_USE_FILE} )
  marble_set_package_properties( Qt4 PROPERTIES DESCRIPTION "cross-platform application framework" )
  marble_set_package_properties( Qt4 PROPERTIES URL "http://qt.digia.com/" )
  marble_set_package_properties( Qt4 PROPERTIES TYPE REQUIRED PURPOSE "core framework" )
  IF ( NOT QT_QTDECLARATIVE_FOUND )
    # older cmake versions have a FindQt4.cmake without support for declarative,
    # but the library may still be available
    FIND_PACKAGE(QtDeclarative)
    include_directories(${QT_QTDECLARATIVE_INCLUDE_DIR})
  ENDIF()
else()
  set( QT5BUILD TRUE )



Thanks guys.

Best regards,
dalishi
dalishi
Registered Member
Posts
10
Karma
0

Re: Marble and Qt5

Wed Jul 29, 2015 2:21 am
Here is how I managed to use marble with Qt5.

1. Download marble stable version (have not tried the master one).
Code: Select all
git clone -b KDE/4.13 git://anongit.kde.org/marble ~/marble_stable/sources

2. Change the CMakeLists.txt. There are two places you will need to change.

For marble_stable/sources/CMakeLists.txt, add the followings:
Code: Select all
 
find_package(Qt5Qml REQUIRED)
find_package(Qt5Quick REQUIRED)

include_directories( ${Qt5Qml_INCLUDE_DIRS} )
include_directories( ${Qt5Quick_INCLUDE_DIRS} )

For marble_stable/sources/src/apps/marble-touch/CMakeLists.txt, add the followings:
Code: Select all
 
if (QT4_FOUND)
  target_link_libraries( marble-touch ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTMAIN_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY} marblewidget )
else()
  target_link_libraries (
    marble-touch
    ...
    ${Qt5Quick_LIBRARIES} # add this line
    ...)
endif()


3. Build marble with Qt5 by setting -DQT5BUILD=TRUE
Code: Select all
cmake -DCMAKE_BUILD_TYPE=Release -DQTONLY=TRUE -DQT5BUILD=TRUE -DCMAKE_PREFIX_PATH=<where you install Qt5>/Qt5.4.0/5.4/gcc_64 -DCMAKE_INSTALL_PREFIX=/usr/local ../sources


4. After you install generated libmarblewidget, compile the example code with Qt5 also.

Code: Select all
#include <marble/MarbleWidget.h>

// For Qt5
#include <QtWidgets/QApplication>
// For Qt 4
//#include <QtGui/QApplication>


int main(int argc, char** argv)
{
    QApplication app(argc, argv);

    // Load Marble using OpenStreetMap in Mercator projection
    Marble::MarbleWidget *mapWidget = new Marble::MarbleWidget;
    mapWidget->setProjection(Marble::Mercator);
    mapWidget->setMapThemeId("earth/openstreetmap/openstreetmap.dgml");

    mapWidget->setWindowTitle("Hello Marble!");
    mapWidget->show();
    return app.exec();
}


5. Done. When you run the hello-marble, remember to have the map theme file in the same directory where you run the executables. Note: you will have to copy the whole data folder (i.e. /marble_stable/sources/data) into the directory not just the "earth/openstreetmap/openstreetmap.dgml" file.

But is this the correct way to do it? ???
wolfi323
Registered Member
Posts
1129
Karma
11
OS

Re: Marble and Qt5  Topic is solved

Wed Jul 29, 2015 8:10 am
I'd say clone and compile the master branch, marble has been ported to Qt5/KF5 already long ago... ;)
There's no need to modify CMakeLists.txt or anything.

Or as the KF5 based marble will be part of the 15.08 release, use "Applications/15.08", or download the Beta from here:
http://download.kde.org/unstable/applic ... 07.80/src/
User avatar
Earthwings
KDE Developer
Posts
172
Karma
1
OS

Re: Marble and Qt5

Wed Jul 29, 2015 10:45 am
wolfi323 is right, please use a more recent branch. Qt 5 is our preferred Qt version now. At the moment we have
  • Applications/15.04: Prefers Qt 4, but Qt 5 is fully supported. Pass -DQT5BUILD=TRUE to build with Qt 5. KDE-wise KDE 4 is used (unless QTONLY=TRUE is set, then KDE support is disabled)
  • Applications/15.08: Prefers Qt 5, but Qt 4 is fully supported. Pass -DQT5BUILD=FALSE to build with Qt 4. KDE-wise KF5 is used. The QTONLY option has been removed, but you can pass WITH_KF5=FALSE to disable KDE support.
  • master: Like Applications/15.08. Current development focuses (among other things) on extending Qt Quick 2 support and doing an Android port.

Most Marble developers are using Qt 5 by now. We plan to keep Qt 4 support though as long as it doesn't get in the way too much. I expect that using Qt 4 will be an option for some years still (at the very least in some LTS branch). Nevertheless I suggest switching to Qt 5 if you have the option to choose.
dalishi
Registered Member
Posts
10
Karma
0

Re: Marble and Qt5

Thu Jul 30, 2015 2:32 am
Thanks both, wolfi323 and Earthwings. I am now quite clear about the development status of marble with Qt 5.

Just some queries (I hope it is not a stupid one):
1. Next time where can I find the relative info like feature changes, variables changes between different branch version numbers?
2. From marble website, I can only find this stable release which is not preferred Qt5 build as I posted in my original post.
Code: Select all
git clone -b KDE/4.13 git://anongit.kde.org/marble ~/marble_stable/sources

Is there a new stable release of Qt5 version of marble soon?

Thanks both.

Have a good day~
User avatar
Earthwings
KDE Developer
Posts
172
Karma
1
OS

Re: Marble and Qt5

Thu Jul 30, 2015 6:28 am
The Marble website indicates that Applications/15.04 is the current stable branch. See the bottom of https://marble.kde.org/changelog.php and https://marble.kde.org/sources.php. I must admit that I corrected the latter just yesterday after reading your post here :<

The branch Applications/15.08 will become the new stable branch in about three weeks on August 19th, see https://techbase.kde.org/Schedules/Appl ... e_Schedule


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, Sogou [Bot]