c++qtubuntuqwt

Qt and qwt installation on ubuntu 18.04.3 LTS: how to connect them?


I installed Qt on Ubuntu via the Qt installer downloaded from the official web page. I developed part of my application and I now need to add graphs, so I tried to install qwt: I found quite easy to do it via the package manager (apt-get). Unfortunately it is not automatically recognized by the Qt I installed. Someone could explain me how to tell Qt to detect the qwt library?

I also tried to install Qt via the package manager, and this time qwt works, but it is an older version, and my application is not working well anymore.

Here is my pro file:

#-------------------------------------------------
#
# Project created by QtCreator 2019-06-04T19:53:08
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Analisi
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

CONFIG += c++11
CONFIG += qwt

SOURCES += \
        main.cpp \
        mainwindow.cpp \
        measure.cpp

HEADERS += \
        gnuplot-iostream.h \
        mainwindow.h \
        measure.h

FORMS += \
        mainwindow.ui

LIBS += -lboost_iostreams -lboost_system -lboost_filesystem

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

edit: I've added the following code to my .bashrc file:

#qwt path for qt designer
#QT_PLUGIN_PATH="/usr/local/qwt-6.1.4/plugins/:$QT_PLUGIN_PATH"
QT_PLUGIN_PATH="/usr/local/qwt-6.1.4/plugins/"
QMAKEFEATURES="/usr/local/qwt-6.1.4/features:$QMAKEFEATURES"
export QT_PLUGIN_PATH
export QMAKEFEATURES

now it is working but only when I start qtcreator from a terminal.


Solution

  • I found the solution and I hope that it could be useful also for other people. Mainly, you need to follow the guide https://qwt.sourceforge.io/qwtinstall.html.

    The problem then is to tell to QtCreator where it can find your library. This can be done creating to environment variables. This is explained in the guide but there is not a clear indication on how to do it on Ubuntu. To create the variables, and made evrithing works when you lunch Qt from the gnome launcher, you need to modify the file "/etc/environment" adding this two lines:

    QT_PLUGIN_PATH="/usr/local/qwt-6.1.4/plugins/:$QT_PLUGIN_PATH"
    QMAKEFEATURES="/usr/local/qwt-6.1.4/features:$QMAKEFEATURES"
    

    This in my case solved the problem. Note that you may need to modify the path accordingly if you installed the Qwt libraries in a custom location.