[solved] Using Merkaartor components in a standalone application
Added by Mathieu Leplatre almost 2 years ago
Hi all,
I am starting a standalone GIS application and would like to reuse most of Merkaartor great widgets and componants.
I need help in order to configure my QtCreator project outside Merkaartor.
So far, I started to develop within the Merkaartor source tree (in a Git branch of course), but I am not fully satisfied as my code will quickly be spread everywhere...
In QtCreator I tried to define a "top" project with two subdirs: merkaartor and mine. But whatever I change in include(*.pri), INCLUDE_PATH and all, MapView.h is never seen nor can compile... What is the best approach/layout ?
If someone has time and skills to give me a hand on that, I would be very grateful... and hope to help in return in some way !
Thank you in advance,
Mathieu
Replies (9)
RE: Using Merkaartor componants in a standalone application
-
Added by Chris Browet almost 2 years ago
My approach is to stuff like that:
.pro
INCLUDEPATH +=src/QFatFs DEPENDPATH += src/QFatFs include(src/QFatFs/QFatFs.pri)
.pri
SOURCES += \
QFatFs.cpp \
QFat.cpp \
QFatFile.cpp
HEADERS += \
QFatFs.h \
QFat.h \
QFatFile.h
This way, I can have kind of "subprojects" while having no issue with #include's
RE: Using Merkaartor componants in a standalone application
-
Added by Mathieu Leplatre almost 2 years ago
Thanks Chris for your light speed answer !
In the particular case of Merkaartor, this would mean :
merkaartor
\_ src
\_ common/common.pri
\_ src.pro
myproject
\_ main.cpp
\_ mywindow.h
\_ mywindow.cpp
\_ myproject.pro
With :
myproject.pro
MERKAARTOR_DIR = $$PWD/../merkaartor
MERKAARTOR_SRC_DIR = $$MERKAARTOR_DIR/src
INCLUDEPATH += $$MERKAARTOR_SRC_DIR $$MERKAARTOR_DIR/include $$MERKAARTOR_DIR/interfaces
DEPENDPATH += $$MERKAARTOR_SRC_DIR $$MERKAARTOR_DIR/include $$MERKAARTOR_DIR/interfaces
INCLUDEPATH += ../merkaartor/src/common
DEPENDPATH += ../merkaartor/src/common
include(../merkaartor/src/common/common.pri)
INCLUDEPATH += ../merkaartor/src/Utils
DEPENDPATH += ../merkaartor/src/Utils
include(../merkaartor/src/common/Utils.pri)
...
...
... Backend, Commands, Render, Layers, Features, Interactions, Preferences, PaintStyle, Docks, ImportExport, GPS, NameFinder
...
...
# Resource file(s)
RESOURCES += ../merkaartor/Icons/AllIcons.qrc \
../merkaartor/share/share.qrc \
../merkaartor/Styles/Styles.qrc
# External dependancies
win32 {
win32-msvc*:LIBS += -lgdal_i
win32-g++:LIBS += -lgdal
}
unix {
LIBS += $$system(gdal-config --libs)
QMAKE_CXXFLAGS += $$system(gdal-config --cflags)
QMAKE_CFLAGS += $$system(gdal-config --cflags)
}
QT += core gui xml svg network webkit
TARGET = myproject
TEMPLATE = app
SOURCES += main.cpp\
mywindow.cpp\
MainWindow.cpp
HEADERS += mywindow.h\
MainWindow.h
FORMS += mywindow.ui
It could compile but could not link because of something that looks strange to me :
../merkaartor/src/MainWindow.cpp: In member function ‘void MainWindow::incomingLocalConnection()’: ../merkaartor/src/MainWindow.cpp:495:50: error: no matching function for call to ‘MainWindow::connect(QTcpSocket*&, const char*, QTcpSocket*&, const char*)’ /usr/include/qt4/QtCore/qobject.h:198:17: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType) /usr/include/qt4/QtCore/qobject.h:313:13: note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
I don't want to bother you, and would prefer asking much more interesting questions, but did I understand well what you suggested ?
Thank you,
Mathieu
myproject.pro (4 kB)
RE: Using Merkaartor componants in a standalone application
-
Added by Chris Browet almost 2 years ago
I don't think this error has something to do with your project structure.
It would look like "MainWindow" is not a QObject anymore? Is it on purpose?
RE: Using Merkaartor componants in a standalone application
-
Added by Mathieu Leplatre almost 2 years ago
Got it !
An #include <QTcpSocket> was missing in Merkaartor MainWindow.cpp, thus considering QTcpSocket as an empty struct as defined in MainWindow.h
(my goal is to use Merkaartor source tree as it is, and avoid hacks as much as possible)
I go on slowly, thank you !
RE: Using Merkaartor componants in a standalone application
-
Added by Mathieu Leplatre almost 2 years ago
Stuck again on QtToolBarDialog... strange, it's probably the most standalone component !
moc_qttoolbardialog.cpp: In member function ‘virtual int QtToolBarDialog::qt_metacall(QMetaObject::Call, int, void**)’: moc_qttoolbardialog.cpp:143:25: error: invalid use of incomplete type ‘struct QtToolBarDialogPrivate’ ../merkaartor/3rdparty/qttoolbardialog-2.2_1-opensource/src/qttoolbardialog.h:104:7: error: forward declaration of ‘struct QtToolBarDialogPrivate’ moc_qttoolbardialog.cpp:144:25: error: invalid use of incomplete type ‘struct QtToolBarDialogPrivate’
even though I added :
include($$MERKAARTOR_DIR/3rdparty/qttoolbardialog-2.2_1-opensource/src/qttoolbardialog.pri)
RE: Using Merkaartor componants in a standalone application
-
Added by Chris Browet almost 2 years ago
When you have incomprehensible "moc" errors, Clean-Qmake-Build is the way to go...
RE: Using Merkaartor componants in a standalone application
-
Added by Mathieu Leplatre almost 2 years ago
Indeed, it was !
(took me time to figure out that some old moc_* files were still in merkaartor source folder...)
In case someone needs a similar setup, please find my example in attachment.
nmtclient.pro (2.3 kB)
RE: [solved] Using Merkaartor components in a standalone application
-
Added by Sophia Purdy over 1 year ago
There is so much that you can get from this blog. I really think you have done such a great job with it. The information and the articles are so good …send flowers to mexico | flowers delivery ukraine
RE: [solved] Using Merkaartor components in a standalone application
-
Added by Andrew Symonds about 1 year ago
Thanks for one more great article about web based predictive dialer. Buy Book Report I am thankful for your great job and for all those useful advices you are giving out in your blog articles. I am looking forward to more other great posts here Online Assignment in the future too! Sincerely Thank you for taking the time to publish this information very useful! I've been looking for books of this nature for a way too long. I'm just glad that I found yours. Looking forward for your next post. Thanks :) Assignment UK
(1-9/9)