在 ubuntu 18.04.3 LTS 上安装 Qt 和 qwt:如何连接它们?

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

本文关键字:何连接 连接 qwt ubuntu LTS Qt 安装      更新时间:2023-10-16

我通过从官方网页下载的Qt安装程序在Ubuntu上安装了Qt。 我开发了部分应用程序,现在需要添加图形,所以我尝试安装 qwt:我发现通过包管理器 (apt-get( 很容易做到这一点。不幸的是,我安装的Qt不会自动识别它。有人可以解释我如何告诉Qt检测qwt库?

我还尝试通过包管理器安装 Qt,这次 qwt 可以工作,但它是旧版本,我的应用程序不再运行良好。

这是我的专业文件:

#-------------------------------------------------
#
# 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

编辑:我已将以下代码添加到我的.bashrc文件中:

#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

现在它正在工作,但只有当我从终端启动 qtcreator 时。

我找到了解决方案,我希望它对其他人也有用。主要是,您需要遵循指南 https://qwt.sourceforge.io/qwtinstall.html。

那么问题就是告诉QtCreator它在哪里可以找到你的库。这可以创建到环境变量。这在指南中有解释,但没有明确说明如何在 Ubuntu 上做到这一点。要创建变量,并在从 gnome 启动器中午读 Qt 时使 evrithing 工作,您需要修改文件"/etc/environment"添加以下两行:

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

就我而言,这解决了问题。 请注意,如果在自定义位置安装了 Qwt 库,则可能需要相应地修改路径。