Qt 连接的引用不明确QQuickItem QMainWindow

Qt 连接的引用不明确QQuickItem QMainWindow,qt,qml,qt-quick,qcustomplot,Qt,Qml,Qt Quick,Qcustomplot,我试图在我的程序中使用以下文件夹的示例: /examples/plots 同时我希望它可以从QML访问。所以,我加了一句,它导致了标题中所述的错误 守则: #include <QQuickItem> #include <QMainWindow> #include <QTimer> #include "../../qcustomplot.h" namespace Ui { class MainWindow; } class MainWi

我试图在我的程序中使用以下文件夹的示例:

/examples/plots

同时我希望它可以从QML访问。所以,我加了一句,它导致了标题中所述的错误

守则:

#include <QQuickItem>
#include <QMainWindow>
#include <QTimer>
#include "../../qcustomplot.h" 

namespace Ui {
class MainWindow;
}

class MainWindow :  public QQuickItem, public QMainWindow
{
  Q_OBJECT
#包括
#包括
#包括
#包括“../../qcustomplot.h”
名称空间用户界面{
类主窗口;
}
类主窗口:公共QQuickItem,公共QMainWindow
{
Q_对象

我应该怎么做才能从QML访问它并解决错误?

有Qt Widgets应用程序和Qt Quick应用程序。选择一个

QCustomPlot
允许您为Qt小部件应用程序创建小部件


您不能在Qt Quick(=QML)应用程序中嵌入QWidget。在某种程度上,您唯一能做的就是在Qt Widgets应用程序中嵌入QML。在这种情况下,
MainWindow
仅继承
QMainWindow
,并包含
QQuickView
(请参阅).

您可以添加一些信息什么是QMainWindow吗?如果它是QWidget的子类,我认为您需要找到一些关于将QQuickView嵌入QWidgets应用程序的文章,反之亦然。