1

I am trying to use QCustomPlot's example of the following folder, in my program:

/examples/plots

and at the same time I want it accessible from QML. So, I added <QQuickItem> and it resulted in the error stated in the title.

The code:

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

namespace Ui {
class MainWindow;
}

class MainWindow :  public QQuickItem, public QMainWindow
{
  Q_OBJECT

What should I do to make it accessible from QML and solve the error too?

4

1 回答 1

1

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

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

您不能在 Qt Quick (=QML) 应用程序中嵌入 QWidget。您唯一能做的就是在您的 Qt Widgets 应用程序中嵌入 QML。在这种情况下,您仅MainWindow继承QMainWindow并包含一个QQuickView(请参阅http://www.ics.com/blog/combining-qt-widgets-and-qml-qwidgetcreatewindowcontainer)。

于 2014-01-29T22:04:12.280 回答