我有2個Qt窗口,即MainWindow
和GraphWindow
; GraphWindow
類的小部件範圍爲QCustomPlot
,其中將繪製來自其他類的數據。在MainWindow
實現文件中,我實例化一個GraphWindow
對象並將其地址傳遞給其他類,以便所有的圖將在同一個窗口中生成。但是我的問題是,當我嘗試傳遞對象的地址時,Qt會拋出以下錯誤;未知類型名稱錯誤Qt C++
Unknown type name GraphWindow
我已經包含在裏面的所有類graphwindow.h
它使用GraphWindow
對象。
這是GraphWindow
類聲明;
#ifndef GRAPHWINDOW_H
#define GRAPHWINDOW_H
#include <QDialog>
#include <mainwindow.h>
#include <incomestatement.h>
#include <balancesheet.h>
#include <cashflow.h>
#include <dcf.h>
#include <QList>
#include <QStringList>
#include <QString>
#include <qcustomplot.h>
#include <QSharedPointer>
#include <QHash>
namespace Ui
{
class GraphWindow;
}
class GraphWindow : public QDialog
{
Q_OBJECT
public:
explicit GraphWindow(QWidget *parent = 0);
~GraphWindow();
void plotData(QStringList labels, QList<double> yData,QString xLabel, QString yLabel, QString slot);
private:
Ui::GraphWindow *ui;
QHash<QString, QCustomPlot* > dynamicWidgetHash;
QStringList widgetStringList;
QVector<double> setupXAxis(QStringList labels, QString slot, QString xLabel);
void setupYAxis(QVector<double> yData, QString slot, QString yLabel);
void setupLegend(QString slot);
void setHash(QStringList widgetStringList);
};
#endif // GRAPHWINDOW_H
這是mainwindow.cpp
其中創建GrapWindow對象;
void MainWindow::on_runButton_clicked()
{
//Create grapher object and pass the address to all sub-classes to plot on the same widget
GraphWindow graphWindow;
if(globalPath.isEmpty() == false)
{
//Create input QXlsx::Document Object
QXlsx::Document inputDoc(globalPath);
// QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
// "/home/jana/untitled.png",
// tr("Images (*.png *.xpm *.jpg)"));
//Create financial statement objects and compute values
IncomeStatement incState(inputDoc,graphWindow);
incState.computePoints(MainWindow::pointsListINC_ST,MainWindow::incSettingList,
MainWindow::incItemList,inputDoc);
}
}
此如果使用GraphWindow
對象的類是incomestatement.h
,一個。
#ifndef INCOMESTATEMENT_H
#define INCOMESTATEMENT_H
#include <QString>
#include <xlsxdocument.h>
#include <xlsxformat.h>
#include <QVector>
#include <QList>
#include <pointssystem.h>
#include <graphwindow.h>
class IncomeStatement
{
//Declare PointsSystem as FRIEND of IncomeStatement to access private members
friend class PointsSystem;
public:
IncomeStatement(QXlsx::Document& inputDoc, GraphWindow& grapher);
//Public member function to be called from mainwindow.cpp
double computePoints(QList<QList<bool> > userSettings, QList<QStringList> itemStringList,
QStringList comboBoxItems, QXlsx::Document& inputDoc);
private:
int cursorRow;
int cursorCol;
double scoredPoints;
double totalPoints;
QStringList timelineList;
QList<double> revenueGrowthArr;
QList<double>costOfRevenGrowthArr;
QList<double>operIncGrowthArr;
QList<double>netIncGrowthArr;
QList<double>totOperExpGrowthArr;
QList<double>grossMarginArr;
QList<double>opIncMarginArr;
QList<double>netIncMarginArr;
QXlsx::Format format(QXlsx::Document& inputDoc, int mode);
bool setSheetName(QXlsx::Document& inputDoc);
void process(QXlsx::Document& inputDoc, GraphWindow& grapher);
int searchKey(QString key,QXlsx::Document& inputDoc);
int findCursorPointRow(QXlsx::Document& inputDoc);
int findCursorPointCol(QXlsx::Document& inputDoc);
void revenueGrowth(QXlsx::Document& inputDoc);
void growthComputation(QXlsx::Document& inputDoc, QString criterion, QList<double>&storageList);
void marginComputation(QXlsx::Document& inputDoc, QString criterion, QList<double>&storageList);
QStringList extractTimeline(QXlsx::Document& inputDoc);
void writeStockAnalysis(QXlsx::Document& inputDoc, QList<QList<QVariant> > data);
void writeStockAnalysisHeader(QXlsx::Document& inputDoc);
void writePointsSumData(QXlsx::Document& inputDoc);
#endif // INCOMESTATEMENT_H
這裏有什麼錯?
你有一個環形集依賴.. – drescherjm
我的天啊,我不能這個愚蠢的:/謝謝老兄:) – Vino
當我開始學習C++ 25到30年前我確信我做了這麼多次。這些天它從來沒有發生在我身上。 – drescherjm