简体   繁体   English

Qt5.12.1未知类型名称QChart / QWidget / QEvent /

[英]Qt5.12.1 Unknown type name QChart / QWidget / QEvent /

I've installed Qt5.12.1 and trying to open a working project but its giving me errors. 我已经安装了Qt5.12.1并尝试打开一个正在运行的项目,但是它给了我错误。 I dont have experience with Qt neither C++ but I need to fix some bugs in this project. 我既没有Qt的经验,也没有C ++的经验,但是我需要修复该项目中的一些错误。 It gives lots of errors like this and I'm using Qt Creator because I dont have access to internet from my work computer. 这样会出现很多错误,我正在使用Qt Creator,因为我无法从工作计算机访问Internet。

Code where it gives error goes like this: 给出错误的代码是这样的:

#include "chartview.h"
#include <QMouseEvent>
#include <qdebug.h>
#include <QtCharts/qxyseries.h>
#include "configvalues.h"
#include "qmath.h"

ChartView::ChartView(QChart *chart , QWidget *parent):
    QChartView(chart,parent), m_isTouching(false), delta(20) {
int rubberBand = ConfigValues::instance()->settings->value(Chart/"RubberBand").toInt();
    QColor c1 = ConfigValues::instance()->settings->value("Chart/TooltipColor").value<QColor>();
    setRubberBand((QChartView::RubberBands) rubberBand);

In this code, QChart and QWidget gives error and because of them so does ChartView. 在这段代码中,QChart和QWidget给出了错误,并且由于它们,ChartView也给出了错误。 Why I'm having these errors? 为什么我有这些错误?

Edit: 编辑:

In ChartView.h file 

#ifndef CHARTVIEW_H
#define CHARTVIEW_H

#include <QchartView>
#include <qrubberband.h>
#include <QDateTime>

exist. 存在。 But only QDateTime is not giving any error. 但是只有QDateTime没有给出任何错误。 Others giving "file not found" 其他人给“找不到文件”

hmmmm hi it'd be much more easier if you would offer an error log also. 嗯,嗨,如果您还提供错误日志,它将更加容易。 but as much as I know these errors are due to the compiler that cannot find the packages mentioned when compiling. 但据我所知,这些错误是由于编译器在编译时找不到所提到的软件包而引起的。 if you have the errors like unknown type : QWidget, QChart, QEvent it probably will be fixed if you import the packages of QtCore and QtCharts to the project and that will be done like this: go to project qmake file like : project.pro add these lines to it: 如果您遇到类似未知类型的错误:QWidget,QChart,QEvent,则将QtCore和QtCharts的包导入到项目中可能会得到解决,并且可以这样进行:转到项目qmake文件,例如:project.pro add这些行:

QT += core widgets charts

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM