【发布时间】:2020-04-29 13:09:43
【问题描述】:
我通过从官方网页下载的 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 时。
【问题讨论】:
-
Qt 不需要连接它。您的代码需要正确链接到它。你是怎么编译的?你在使用 Cmake/Qmake 吗?
-
我认为这不是一个好的答案,但我只知道我正在使用 Qt Creator 上的“运行”按钮(通过 Qt 安装程序安装)。我是 Qt 的新手,你知道我在哪里可以找到你需要的信息吗?我无法在 QtDesigner 中看到 qwt 小部件,所以我不知道如何使用它们。
-
感谢@eyllanesc,在配置文件中显示“使用 QWT_INSTALL_PREFIX 下方的路径时,您需要在设计器/创建者的运行时环境中将 $${QWT_INSTALL_PREFIX}/plugins 添加到 QT_PLUGIN_PATH”。你知道我该怎么做吗?
-
它在哪里说的?