我通过从官方网页下载的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时。
答案 0 :(得分:0)
我找到了解决方案,希望对其他人也有用。主要是,您需要遵循指南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库安装在自定义位置,则可能需要相应地修改路径。